def put(self, instance):
key = objectstore.get_instance_key(instance, self.class_, self.table, self.selectable)
- instance._instance_key = key
objectstore.put(key, instance, self.scope)
return key
def save_obj(self, obj):
# TODO: start breaking down the individual updates/inserts into the UOW or something,
# so they can be combined into a multiple execute
+ if hasattr(obj, "_instance_key"):
+ isinsert = False
+ else:
+ isinsert = True
+
for table in self.tables:
params = {}
- if hasattr(obj, "_instance_key"):
- isinsert = False
- else:
- isinsert = True
needs_primaries = False
for primary_key in table.primary_keys:
if self._getattrbycolumn(obj, primary_key) is None:
needs_primaries = True
- #statement = table.insert()
if isinsert:
for col in table.columns:
params[col.key] = self._getattrbycolumn(obj, col)
clause.clauses.append(col == self._getattrbycolumn(obj, col))
else:
params[col.key] = self._getattrbycolumn(obj, col)
- #statement = table.update(clause)
if not isinsert:
statement = table.update(clause)
newid = primary_keys[index]
index += 1
self._setattrbycolumn(obj, col, newid)
- self.put(obj)
+ #self.put(obj)
def register_dependencies(self, obj, uow):
for prop in self.props.values():