# HG changeset patch # User Sylvain Thénault # Date 1260290886 -3600 # Node ID 12c4f7e2bed61e09af6bfc619fcc3691116060b8 # Parent 2989a7d50b2882a3547d28ae0b505cd629b50c44 had been involontarly dropped diff -r 2989a7d50b28 -r 12c4f7e2bed6 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) +