equal
deleted
inserted
replaced
67 |
67 |
68 class _SetCreatorOp(hook.Operation): |
68 class _SetCreatorOp(hook.Operation): |
69 |
69 |
70 def precommit_event(self): |
70 def precommit_event(self): |
71 session = self.session |
71 session = self.session |
72 for eid in session.transaction_data['set_creator_op']: |
72 for eid in session.transaction_data.pop('set_creator_op'): |
73 if session.deleted_in_transaction(eid): |
73 if session.deleted_in_transaction(eid): |
74 # entity have been created and deleted in the same transaction |
74 # entity have been created and deleted in the same transaction |
75 continue |
75 continue |
76 entity = session.entity_from_eid(eid) |
76 entity = session.entity_from_eid(eid) |
77 if not entity.created_by: |
77 if not entity.created_by: |
112 self._cw.add_relation(self.entity.eid, 'owned_by', self._cw.user.eid) |
112 self._cw.add_relation(self.entity.eid, 'owned_by', self._cw.user.eid) |
113 hook.set_operation(self._cw, 'set_creator_op', self.entity.eid, _SetCreatorOp) |
113 hook.set_operation(self._cw, 'set_creator_op', self.entity.eid, _SetCreatorOp) |
114 |
114 |
115 class _SyncOwnersOp(hook.Operation): |
115 class _SyncOwnersOp(hook.Operation): |
116 def precommit_event(self): |
116 def precommit_event(self): |
117 for compositeeid, composedeid in self.session.transaction_data['sync_owners_op']: |
117 for compositeeid, composedeid in self.session.transaction_data.pop('sync_owners_op'): |
118 self.session.execute('SET X owned_by U WHERE C owned_by U, C eid %(c)s,' |
118 self.session.execute('SET X owned_by U WHERE C owned_by U, C eid %(c)s,' |
119 'NOT EXISTS(X owned_by U, X eid %(x)s)', |
119 'NOT EXISTS(X owned_by U, X eid %(x)s)', |
120 {'c': compositeeid, 'x': composedeid}) |
120 {'c': compositeeid, 'x': composedeid}) |
121 |
121 |
122 |
122 |