equal
deleted
inserted
replaced
51 |
51 |
52 |
52 |
53 class _CheckEntityPermissionOp(hook.LateOperation): |
53 class _CheckEntityPermissionOp(hook.LateOperation): |
54 def precommit_event(self): |
54 def precommit_event(self): |
55 #print 'CheckEntityPermissionOp', self.session.user, self.entity, self.action |
55 #print 'CheckEntityPermissionOp', self.session.user, self.entity, self.action |
56 self.entity.check_perm(self.action) |
56 session = self.session |
57 check_entity_attributes(self.session, self.entity, self.editedattrs) |
57 for values in session.transaction_data['check_entity_perm_op']: |
|
58 entity = session.entity_from_eid(values[0]) |
|
59 action = values[1] |
|
60 entity.check_perm(action) |
|
61 check_entity_attributes(session, entity, values[2:]) |
58 |
62 |
59 def commit_event(self): |
63 def commit_event(self): |
60 pass |
64 pass |
61 |
65 |
62 |
66 |
87 class AfterAddEntitySecurityHook(SecurityHook): |
91 class AfterAddEntitySecurityHook(SecurityHook): |
88 __regid__ = 'securityafteraddentity' |
92 __regid__ = 'securityafteraddentity' |
89 events = ('after_add_entity',) |
93 events = ('after_add_entity',) |
90 |
94 |
91 def __call__(self): |
95 def __call__(self): |
92 _CheckEntityPermissionOp(self._cw, entity=self.entity, |
96 hook.set_operation(self._cw, 'check_entity_perm_op', |
93 editedattrs=tuple(self.entity.edited_attributes), |
97 (self.entity.eid, 'add') + tuple(self.entity.edited_attributes), |
94 action='add') |
98 _CheckEntityPermissionOp) |
95 |
99 |
96 |
100 |
97 class AfterUpdateEntitySecurityHook(SecurityHook): |
101 class AfterUpdateEntitySecurityHook(SecurityHook): |
98 __regid__ = 'securityafterupdateentity' |
102 __regid__ = 'securityafterupdateentity' |
99 events = ('after_update_entity',) |
103 events = ('after_update_entity',) |
106 except Unauthorized: |
110 except Unauthorized: |
107 self.entity.clear_local_perm_cache('update') |
111 self.entity.clear_local_perm_cache('update') |
108 # save back editedattrs in case the entity is reedited later in the |
112 # save back editedattrs in case the entity is reedited later in the |
109 # same transaction, which will lead to edited_attributes being |
113 # same transaction, which will lead to edited_attributes being |
110 # overwritten |
114 # overwritten |
111 _CheckEntityPermissionOp(self._cw, entity=self.entity, |
115 hook.set_operation(self._cw, 'check_entity_perm_op', |
112 editedattrs=tuple(self.entity.edited_attributes), |
116 (self.entity.eid, 'update') + tuple(self.entity.edited_attributes), |
113 action='update') |
117 _CheckEntityPermissionOp) |
114 |
118 |
115 |
119 |
116 class BeforeDelEntitySecurityHook(SecurityHook): |
120 class BeforeDelEntitySecurityHook(SecurityHook): |
117 __regid__ = 'securitybeforedelentity' |
121 __regid__ = 'securitybeforedelentity' |
118 events = ('before_delete_entity',) |
122 events = ('before_delete_entity',) |