equal
deleted
inserted
replaced
461 |
461 |
462 def __call__(self, cls, req, *args, **kwargs): |
462 def __call__(self, cls, req, *args, **kwargs): |
463 if kwargs.get('rtype') not in self.expected: |
463 if kwargs.get('rtype') not in self.expected: |
464 return 0 |
464 return 0 |
465 if self.frometypes is not None and \ |
465 if self.frometypes is not None and \ |
466 req.entity_metas(kwargs['eidfrom'])['type'] not in self.frometypes: |
466 req.entity_type(kwargs['eidfrom']) not in self.frometypes: |
467 return 0 |
467 return 0 |
468 if self.toetypes is not None and \ |
468 if self.toetypes is not None and \ |
469 req.entity_metas(kwargs['eidto'])['type'] not in self.toetypes: |
469 req.entity_type(kwargs['eidto']) not in self.toetypes: |
470 return 0 |
470 return 0 |
471 return 1 |
471 return 1 |
472 |
472 |
473 |
473 |
474 class match_rtype_sets(ExpectedValuePredicate): |
474 class match_rtype_sets(ExpectedValuePredicate): |
605 object_relations = None |
605 object_relations = None |
606 |
606 |
607 def __call__(self): |
607 def __call__(self): |
608 assert self.main_rtype |
608 assert self.main_rtype |
609 for eid in (self.eidfrom, self.eidto): |
609 for eid in (self.eidfrom, self.eidto): |
610 etype = self._cw.entity_metas(eid)['type'] |
610 etype = self._cw.entity_type(eid) |
611 if self.main_rtype not in self._cw.vreg.schema.eschema(etype).subjrels: |
611 if self.main_rtype not in self._cw.vreg.schema.eschema(etype).subjrels: |
612 return |
612 return |
613 if self.rtype in self.subject_relations: |
613 if self.rtype in self.subject_relations: |
614 meid, seid = self.eidfrom, self.eidto |
614 meid, seid = self.eidfrom, self.eidto |
615 else: |
615 else: |
641 # to set in concrete class (optionally) |
641 # to set in concrete class (optionally) |
642 skip_subject_relations = () |
642 skip_subject_relations = () |
643 skip_object_relations = () |
643 skip_object_relations = () |
644 |
644 |
645 def __call__(self): |
645 def __call__(self): |
646 eschema = self._cw.vreg.schema.eschema(self._cw.entity_metas(self.eidfrom)['type']) |
646 eschema = self._cw.vreg.schema.eschema(self._cw.entity_type(self.eidfrom)) |
647 execute = self._cw.execute |
647 execute = self._cw.execute |
648 for rel in self.subject_relations: |
648 for rel in self.subject_relations: |
649 if rel in eschema.subjrels and not rel in self.skip_subject_relations: |
649 if rel in eschema.subjrels and not rel in self.skip_subject_relations: |
650 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
650 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
651 'X %s R, NOT R %s P' % (self.rtype, rel, self.rtype), |
651 'X %s R, NOT R %s P' % (self.rtype, rel, self.rtype), |
665 documentation for how to use this class. |
665 documentation for how to use this class. |
666 """ |
666 """ |
667 events = ('after_delete_relation',) |
667 events = ('after_delete_relation',) |
668 |
668 |
669 def __call__(self): |
669 def __call__(self): |
670 eschema = self._cw.vreg.schema.eschema(self._cw.entity_metas(self.eidfrom)['type']) |
670 eschema = self._cw.vreg.schema.eschema(self._cw.entity_type(self.eidfrom)) |
671 execute = self._cw.execute |
671 execute = self._cw.execute |
672 for rel in self.subject_relations: |
672 for rel in self.subject_relations: |
673 if rel in eschema.subjrels and not rel in self.skip_subject_relations: |
673 if rel in eschema.subjrels and not rel in self.skip_subject_relations: |
674 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
674 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
675 'X %s R' % (self.rtype, rel), |
675 'X %s R' % (self.rtype, rel), |