680 execute = getattr(self.req, 'unsafe_execute', self.req.execute) |
680 execute = getattr(self.req, 'unsafe_execute', self.req.execute) |
681 rset = execute(rql, {'x': self.eid}, 'x') |
681 rset = execute(rql, {'x': self.eid}, 'x') |
682 self.set_related_cache(rtype, role, rset) |
682 self.set_related_cache(rtype, role, rset) |
683 return self.related(rtype, role, limit, entities) |
683 return self.related(rtype, role, limit, entities) |
684 |
684 |
685 def related_rql(self, rtype, role='subject'): |
685 def related_rql(self, rtype, role='subject', targettypes=None): |
686 rschema = self.schema[rtype] |
686 rschema = self.schema[rtype] |
687 if role == 'subject': |
687 if role == 'subject': |
688 targettypes = rschema.objects(self.e_schema) |
688 if targettypes is None: |
|
689 targettypes = rschema.objects(self.e_schema) |
689 restriction = 'E eid %%(x)s, E %s X' % rtype |
690 restriction = 'E eid %%(x)s, E %s X' % rtype |
690 card = greater_card(rschema, (self.e_schema,), targettypes, 0) |
691 card = greater_card(rschema, (self.e_schema,), targettypes, 0) |
691 else: |
692 else: |
692 targettypes = rschema.subjects(self.e_schema) |
693 if targettypes is None: |
|
694 targettypes = rschema.subjects(self.e_schema) |
693 restriction = 'E eid %%(x)s, X %s E' % rtype |
695 restriction = 'E eid %%(x)s, X %s E' % rtype |
694 card = greater_card(rschema, targettypes, (self.e_schema,), 1) |
696 card = greater_card(rschema, targettypes, (self.e_schema,), 1) |
695 if len(targettypes) > 1: |
697 if len(targettypes) > 1: |
696 fetchattrs_list = [] |
698 fetchattrs_list = [] |
697 for ttype in targettypes: |
699 for ttype in targettypes: |