702 restriction = 'S eid %(s)s, O eid %(o)s, ' + self.restriction |
702 restriction = 'S eid %(s)s, O eid %(o)s, ' + self.restriction |
703 args, ck = {'s': eidfrom, 'o': eidto}, ('s', 'o') |
703 args, ck = {'s': eidfrom, 'o': eidto}, ('s', 'o') |
704 rql = 'Any %s WHERE %s' % (self.mainvars, restriction) |
704 rql = 'Any %s WHERE %s' % (self.mainvars, restriction) |
705 if self.distinct_query: |
705 if self.distinct_query: |
706 rql = 'DISTINCT ' + rql |
706 rql = 'DISTINCT ' + rql |
707 return session.unsafe_execute(rql, args, ck, build_descr=False) |
707 return session.execute(rql, args, ck, build_descr=False) |
708 |
708 |
709 |
709 |
710 class RQLConstraint(RepoEnforcedRQLConstraintMixIn, RQLVocabularyConstraint): |
710 class RQLConstraint(RepoEnforcedRQLConstraintMixIn, RQLVocabularyConstraint): |
711 """the rql constraint is similar to the RQLVocabularyConstraint but |
711 """the rql constraint is similar to the RQLVocabularyConstraint but |
712 are also enforced at the repository level |
712 are also enforced at the repository level |
828 # when creating an entity, consider has_*_permission satisfied |
828 # when creating an entity, consider has_*_permission satisfied |
829 if has_perm_defs: |
829 if has_perm_defs: |
830 return True |
830 return True |
831 return False |
831 return False |
832 if keyarg is None: |
832 if keyarg is None: |
833 # on the server side, use unsafe_execute, but this is not available |
|
834 # on the client side (session is actually a request) |
|
835 execute = getattr(session, 'unsafe_execute', session.execute) |
|
836 kwargs.setdefault('u', session.user.eid) |
833 kwargs.setdefault('u', session.user.eid) |
837 cachekey = kwargs.keys() |
834 cachekey = kwargs.keys() |
838 try: |
835 try: |
839 rset = execute(rql, kwargs, cachekey, build_descr=True) |
836 rset = session.execute(rql, kwargs, cachekey, build_descr=True) |
840 except NotImplementedError: |
837 except NotImplementedError: |
841 self.critical('cant check rql expression, unsupported rql %s', rql) |
838 self.critical('cant check rql expression, unsupported rql %s', rql) |
842 if self.eid is not None: |
839 if self.eid is not None: |
843 session.local_perm_cache[key] = False |
840 session.local_perm_cache[key] = False |
844 return False |
841 return False |
1082 if form is None and entity is not None: |
1079 if form is None and entity is not None: |
1083 cw = entity._cw |
1080 cw = entity._cw |
1084 elif form is not None: |
1081 elif form is not None: |
1085 cw = form._cw |
1082 cw = form._cw |
1086 if cw is not None: |
1083 if cw is not None: |
1087 if hasattr(cw, 'is_super_session'): |
1084 if hasattr(cw, 'write_security'): # test it's a session and not a request |
1088 # cw is a server session |
1085 # cw is a server session |
1089 hasperm = cw.is_super_session or \ |
1086 hasperm = not cw.write_security or \ |
1090 not cw.is_hooks_category_activated('integrity') or \ |
1087 not cw.is_hooks_category_activated('integrity') or \ |
1091 cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1088 cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1092 else: |
1089 else: |
1093 hasperm = cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1090 hasperm = cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1094 if hasperm: |
1091 if hasperm: |