703 |
703 |
704 def exec_query(self, session, eidfrom, eidto): |
704 def exec_query(self, session, eidfrom, eidto): |
705 if eidto is None: |
705 if eidto is None: |
706 # checking constraint for an attribute relation |
706 # checking constraint for an attribute relation |
707 restriction = 'S eid %(s)s, ' + self.restriction |
707 restriction = 'S eid %(s)s, ' + self.restriction |
708 args, ck = {'s': eidfrom}, 's' |
708 args = {'s': eidfrom} |
709 else: |
709 else: |
710 restriction = 'S eid %(s)s, O eid %(o)s, ' + self.restriction |
710 restriction = 'S eid %(s)s, O eid %(o)s, ' + self.restriction |
711 args, ck = {'s': eidfrom, 'o': eidto}, ('s', 'o') |
711 args = {'s': eidfrom, 'o': eidto} |
712 rql = 'Any %s WHERE %s' % (self.mainvars, restriction) |
712 rql = 'Any %s WHERE %s' % (self.mainvars, restriction) |
713 if self.distinct_query: |
713 if self.distinct_query: |
714 rql = 'DISTINCT ' + rql |
714 rql = 'DISTINCT ' + rql |
715 return session.execute(rql, args, ck, build_descr=False) |
715 return session.execute(rql, args, build_descr=False) |
716 |
716 |
717 |
717 |
718 class RQLConstraint(RepoEnforcedRQLConstraintMixIn, RQLVocabularyConstraint): |
718 class RQLConstraint(RepoEnforcedRQLConstraintMixIn, RQLVocabularyConstraint): |
719 """the rql constraint is similar to the RQLVocabularyConstraint but |
719 """the rql constraint is similar to the RQLVocabularyConstraint but |
720 are also enforced at the repository level |
720 are also enforced at the repository level |
837 if has_perm_defs: |
837 if has_perm_defs: |
838 return True |
838 return True |
839 return False |
839 return False |
840 if keyarg is None: |
840 if keyarg is None: |
841 kwargs.setdefault('u', session.user.eid) |
841 kwargs.setdefault('u', session.user.eid) |
842 cachekey = kwargs.keys() |
|
843 try: |
842 try: |
844 rset = session.execute(rql, kwargs, cachekey, build_descr=True) |
843 rset = session.execute(rql, kwargs, build_descr=True) |
845 except NotImplementedError: |
844 except NotImplementedError: |
846 self.critical('cant check rql expression, unsupported rql %s', rql) |
845 self.critical('cant check rql expression, unsupported rql %s', rql) |
847 if self.eid is not None: |
846 if self.eid is not None: |
848 session.local_perm_cache[key] = False |
847 session.local_perm_cache[key] = False |
849 return False |
848 return False |