server/hook.py
changeset 4104 7e478d7caf20
parent 4086 9b96126e0b14
child 4106 ea4e93f9b151
equal deleted inserted replaced
4103:dc04bede3502 4104:7e478d7caf20
   244     object_relations = None
   244     object_relations = None
   245 
   245 
   246     def __call__(self):
   246     def __call__(self):
   247         for eid in (self.eidfrom, self.eidto):
   247         for eid in (self.eidfrom, self.eidto):
   248             etype = self._cw.describe(eid)[0]
   248             etype = self._cw.describe(eid)[0]
   249             if not self.schema.eschema(etype).has_subject_relation(self.main_rtype):
   249             if not self._cw.vreg.schema.eschema(etype).has_subject_relation(self.main_rtype):
   250                 return
   250                 return
   251         if self.rtype in self.subject_relations:
   251         if self.rtype in self.subject_relations:
   252             meid, seid = self.eidfrom, self.eidto
   252             meid, seid = self.eidfrom, self.eidto
   253         else:
   253         else:
   254             assert self.rtype in self.object_relations
   254             assert self.rtype in self.object_relations
   267     main_rtype = None
   267     main_rtype = None
   268     subject_relations = None
   268     subject_relations = None
   269     object_relations = None
   269     object_relations = None
   270 
   270 
   271     def __call__(self):
   271     def __call__(self):
   272         eschema = self.schema.eschema(self._cw.describe(self.eidfrom)[0])
   272         eschema = self._cw.vreg.schema.eschema(self._cw.describe(self.eidfrom)[0])
   273         execute = self._cw.unsafe_execute
   273         execute = self._cw.unsafe_execute
   274         for rel in self.subject_relations:
   274         for rel in self.subject_relations:
   275             if rel in eschema.subjrels:
   275             if rel in eschema.subjrels:
   276                 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
   276                 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
   277                         'X %s R, NOT R %s P' % (self.rtype, rel, self.rtype),
   277                         'X %s R, NOT R %s P' % (self.rtype, rel, self.rtype),
   291     main_rtype = None
   291     main_rtype = None
   292     subject_relations = None
   292     subject_relations = None
   293     object_relations = None
   293     object_relations = None
   294 
   294 
   295     def __call__(self):
   295     def __call__(self):
   296         eschema = self.schema.eschema(self._cw.describe(self.eidfrom)[0])
   296         eschema = self._cw.vreg.schema.eschema(self._cw.describe(self.eidfrom)[0])
   297         execute = self._cw.unsafe_execute
   297         execute = self._cw.unsafe_execute
   298         for rel in self.subject_relations:
   298         for rel in self.subject_relations:
   299             if rel in eschema.subjrels:
   299             if rel in eschema.subjrels:
   300                 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
   300                 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
   301                         'X %s R' % (self.rtype, rel),
   301                         'X %s R' % (self.rtype, rel),