hooks/security.py
changeset 4048 12c4f7e2bed6
parent 4003 b9436fe77c9e
child 4190 742e3eb16f81
--- 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)
+