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