hooks/security.py
changeset 4048 12c4f7e2bed6
parent 4003 b9436fe77c9e
child 4190 742e3eb16f81
equal deleted inserted replaced
4047:2989a7d50b28 4048:12c4f7e2bed6
   121             else:
   121             else:
   122                 rdef = rschema.rdef(self._cw.describe(self.eidfrom)[0],
   122                 rdef = rschema.rdef(self._cw.describe(self.eidfrom)[0],
   123                                     self._cw.describe(self.eidto)[0])
   123                                     self._cw.describe(self.eidto)[0])
   124                 rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto)
   124                 rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto)
   125 
   125 
       
   126 
       
   127 class BeforeDeleteRelationSecurityHook(SecurityHook):
       
   128     __regid__ = 'securitybeforedelrelation'
       
   129     events = ('before_delete_relation',)
       
   130 
       
   131     def __call__(self):
       
   132         nocheck = self._cw.transaction_data.get('skip-security', ())
       
   133         if (self.eidfrom, self.rtype, self.eidto) in nocheck:
       
   134             return
       
   135         rschema = self._cw.repo.schema[self.rtype]
       
   136         rdef = rschema.rdef(self._cw.describe(self.eidfrom)[0],
       
   137                             self._cw.describe(self.eidto)[0])
       
   138         rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto)
       
   139