Refactor Query.get()
=> Session.get()
per SQLAlchemy 1.4
This commit is contained in:
parent
81aa0ae109
commit
f611a5a521
38 changed files with 169 additions and 205 deletions
|
@ -32,7 +32,6 @@ import logging
|
|||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
from six import StringIO
|
||||
|
||||
import json
|
||||
import markdown
|
||||
|
@ -236,7 +235,7 @@ class BatchMasterView(MasterView):
|
|||
Thread target for updating a batch from worksheet.
|
||||
"""
|
||||
session = self.make_isolated_session()
|
||||
batch = session.query(self.model_class).get(batch_uuid)
|
||||
batch = session.get(self.model_class, batch_uuid)
|
||||
try:
|
||||
self.handler.update_from_worksheet(batch, path, progress=progress)
|
||||
|
||||
|
@ -1020,7 +1019,7 @@ class BatchMasterView(MasterView):
|
|||
|
||||
def catchup_versions(self, port, batch_uuid, username, *models):
|
||||
with short_session() as s:
|
||||
batch = s.query(self.model_class).get(batch_uuid)
|
||||
batch = s.get(self.model_class, batch_uuid)
|
||||
batch_id = batch.id_str
|
||||
description = str(batch)
|
||||
|
||||
|
@ -1047,8 +1046,8 @@ class BatchMasterView(MasterView):
|
|||
"""
|
||||
# mustn't use tailbone web session here
|
||||
session = RattailSession()
|
||||
batch = session.query(self.model_class).get(batch_uuid)
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
batch = session.get(self.model_class, batch_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
try:
|
||||
self.handler.do_populate(batch, user, progress=progress)
|
||||
session.flush()
|
||||
|
@ -1104,8 +1103,8 @@ class BatchMasterView(MasterView):
|
|||
# rattail session here; can't use tailbone because it has web request
|
||||
# transaction binding etc.
|
||||
session = RattailSession()
|
||||
batch = session.query(self.model_class).get(batch_uuid)
|
||||
cognizer = session.query(model.User).get(user_uuid) if user_uuid else None
|
||||
batch = session.get(self.model_class, batch_uuid)
|
||||
cognizer = session.get(model.User, user_uuid) if user_uuid else None
|
||||
try:
|
||||
self.refresh_data(session, batch, cognizer, progress=progress)
|
||||
session.flush()
|
||||
|
@ -1158,7 +1157,7 @@ class BatchMasterView(MasterView):
|
|||
"""
|
||||
session = RattailSession()
|
||||
batches = batches.with_session(session).all()
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
try:
|
||||
self.handler.refresh_many(batches, user=user, progress=progress)
|
||||
|
||||
|
@ -1298,7 +1297,7 @@ class BatchMasterView(MasterView):
|
|||
# transaction binding etc.
|
||||
session = RattailSession()
|
||||
batch = self.get_instance_for_key(key, session)
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
try:
|
||||
result = self.handler.do_execute(batch, user=user, progress=progress, **kwargs)
|
||||
|
||||
|
@ -1373,7 +1372,7 @@ class BatchMasterView(MasterView):
|
|||
"""
|
||||
session = RattailSession()
|
||||
batches = batches.with_session(session).all()
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
try:
|
||||
result = self.handler.execute_many(batches, user=user, progress=progress, **kwargs)
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ class ImporterBatchView(BatchMasterView):
|
|||
|
||||
def get_parent(self, row):
|
||||
uuid = self.current_row_table.name
|
||||
return self.Session.query(model.ImporterBatch).get(uuid)
|
||||
return self.Session.get(model.ImporterBatch, uuid)
|
||||
|
||||
def get_row_instance_title(self, row):
|
||||
if row.object_str:
|
||||
|
|
|
@ -214,7 +214,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
return super(InventoryBatchView, self).save_edit_row_form(form)
|
||||
|
||||
def delete_row(self):
|
||||
row = self.Session.query(model.InventoryBatchRow).get(self.request.matchdict['row_uuid'])
|
||||
row = self.Session.get(model.InventoryBatchRow, self.request.matchdict['row_uuid'])
|
||||
if not row:
|
||||
raise self.notfound()
|
||||
batch = row.batch
|
||||
|
@ -235,7 +235,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
if self.request.method == 'POST':
|
||||
if form.validate(newstyle=True):
|
||||
|
||||
product = self.Session.query(model.Product).get(form.validated['product'])
|
||||
product = self.Session.get(model.Product, form.validated['product'])
|
||||
|
||||
row = None
|
||||
if self.should_aggregate_products(batch):
|
||||
|
@ -515,7 +515,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
def valid_product(node, kw):
|
||||
session = kw['session']
|
||||
def validate(node, value):
|
||||
product = session.query(model.Product).get(value)
|
||||
product = session.get(model.Product, value)
|
||||
if not product:
|
||||
raise colander.Invalid(node, "Product not found")
|
||||
return product.uuid
|
||||
|
|
|
@ -225,8 +225,8 @@ class VendorCatalogView(FileBatchMasterView):
|
|||
vendor_display = ""
|
||||
if self.request.method == 'POST':
|
||||
if self.request.POST.get('vendor_uuid'):
|
||||
vendor = self.Session.query(model.Vendor).get(
|
||||
self.request.POST['vendor_uuid'])
|
||||
vendor = self.Session.get(model.Vendor,
|
||||
self.request.POST['vendor_uuid'])
|
||||
if vendor:
|
||||
vendor_display = str(vendor)
|
||||
f.set_widget('vendor_uuid',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue