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
|
@ -1024,7 +1024,7 @@ class MasterView(View):
|
|||
"""
|
||||
# mustn't use tailbone web session here
|
||||
session = RattailSession()
|
||||
obj = session.query(self.model_class).get(uuid)
|
||||
obj = session.get(self.model_class, uuid)
|
||||
try:
|
||||
self.populate_object(session, obj, progress=progress)
|
||||
except Exception as error:
|
||||
|
@ -1727,7 +1727,7 @@ class MasterView(View):
|
|||
if uuids:
|
||||
uuids = uuids.split(',')
|
||||
# TODO: probably need to allow override of fetcher callable
|
||||
fetcher = lambda uuid: self.Session.query(self.model_class).get(uuid)
|
||||
fetcher = lambda uuid: self.Session.get(self.model_class, uuid)
|
||||
objects = []
|
||||
for uuid in uuids:
|
||||
obj = fetcher(uuid)
|
||||
|
@ -1856,7 +1856,7 @@ class MasterView(View):
|
|||
model_key = self.get_model_key(as_tuple=True)
|
||||
if len(model_key) == 1 and model_key[0] == 'uuid':
|
||||
uuid = key[0]
|
||||
return session.query(self.model_class).get(uuid)
|
||||
return session.get(self.model_class, uuid)
|
||||
raise NotImplementedError
|
||||
|
||||
def execute_thread(self, key, user_uuid, progress=None, **kwargs):
|
||||
|
@ -1865,7 +1865,7 @@ class MasterView(View):
|
|||
"""
|
||||
session = RattailSession()
|
||||
obj = self.get_instance_for_key(key, session)
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
try:
|
||||
success_msg = self.execute_instance(obj, user,
|
||||
progress=progress,
|
||||
|
@ -2021,8 +2021,8 @@ class MasterView(View):
|
|||
if self.request.method == 'POST':
|
||||
uuids = self.request.POST.get('uuids', '').split(',')
|
||||
if len(uuids) == 2:
|
||||
object_to_remove = self.Session.query(self.get_model_class()).get(uuids[0])
|
||||
object_to_keep = self.Session.query(self.get_model_class()).get(uuids[1])
|
||||
object_to_remove = self.Session.get(self.get_model_class(), uuids[0])
|
||||
object_to_keep = self.Session.get(self.get_model_class(), uuids[1])
|
||||
|
||||
if object_to_remove and object_to_keep and self.request.POST.get('commit-merge') == 'yes':
|
||||
msg = str(object_to_remove)
|
||||
|
@ -4447,7 +4447,7 @@ class MasterView(View):
|
|||
# TODO: is this right..?
|
||||
# key = self.request.matchdict[self.get_model_key()]
|
||||
key = self.request.matchdict['row_uuid']
|
||||
instance = self.Session.query(self.model_row_class).get(key)
|
||||
instance = self.Session.get(self.model_row_class, key)
|
||||
if not instance:
|
||||
raise self.notfound()
|
||||
return instance
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue