had been involontarly dropped
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 08 Dec 2009 17:48:06 +0100
changeset 4048 12c4f7e2bed6
parent 4047 2989a7d50b28
child 4049 5838a4b0766d
had been involontarly dropped
hooks/security.py
--- a/hooks/security.py	Tue Dec 08 17:11:47 2009 +0100
+++ b/hooks/security.py	Tue Dec 08 17:48:06 2009 +0100
@@ -123,3 +123,17 @@
                                     self._cw.describe(self.eidto)[0])
                 rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto)
 
+
+class BeforeDeleteRelationSecurityHook(SecurityHook):
+    __regid__ = 'securitybeforedelrelation'
+    events = ('before_delete_relation',)
+
+    def __call__(self):
+        nocheck = self._cw.transaction_data.get('skip-security', ())
+        if (self.eidfrom, self.rtype, self.eidto) in nocheck:
+            return
+        rschema = self._cw.repo.schema[self.rtype]
+        rdef = rschema.rdef(self._cw.describe(self.eidfrom)[0],
+                            self._cw.describe(self.eidto)[0])
+        rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto)
+