equal
deleted
inserted
replaced
65 |
65 |
66 class SetCreatorOp(hook.DataOperationMixIn, hook.Operation): |
66 class SetCreatorOp(hook.DataOperationMixIn, hook.Operation): |
67 |
67 |
68 def precommit_event(self): |
68 def precommit_event(self): |
69 session = self.session |
69 session = self.session |
70 for eid in self.get_data(): |
70 relations = [(eid, session.user.eid) for eid in self.get_data() |
71 if session.deleted_in_transaction(eid): |
71 # don't consider entities that have been created and |
72 # entity have been created and deleted in the same transaction |
72 # deleted in the same transaction |
73 continue |
73 if not session.deleted_in_transaction(eid) and \ |
74 entity = session.entity_from_eid(eid) |
74 not session.entity_from_eid(eid).created_by] |
75 if not entity.created_by: |
75 session.add_relations([('created_by', relations)]) |
76 session.add_relation(eid, 'created_by', session.user.eid) |
|
77 |
76 |
78 |
77 |
79 class SetOwnershipHook(MetaDataHook): |
78 class SetOwnershipHook(MetaDataHook): |
80 """create a new entity -> set owner and creator metadata""" |
79 """create a new entity -> set owner and creator metadata""" |
81 __regid__ = 'setowner' |
80 __regid__ = 'setowner' |