schema.py
branchstable
changeset 4619 f4254586e867
parent 4608 181c877b3048
child 4702 d9e51820d0c2
equal deleted inserted replaced
4618:412a9f1f5fd0 4619:f4254586e867
   804             return False
   804             return False
   805         if keyarg is None:
   805         if keyarg is None:
   806             # on the server side, use unsafe_execute, but this is not available
   806             # on the server side, use unsafe_execute, but this is not available
   807             # on the client side (session is actually a request)
   807             # on the client side (session is actually a request)
   808             execute = getattr(session, 'unsafe_execute', session.execute)
   808             execute = getattr(session, 'unsafe_execute', session.execute)
   809             # XXX what if 'u' in kwargs
   809             kwargs.setdefault('u', session.user.eid)
   810             cachekey = kwargs.keys()
   810             cachekey = kwargs.keys()
   811             kwargs['u'] = session.user.eid
       
   812             try:
   811             try:
   813                 rset = execute(rql, kwargs, cachekey, build_descr=True)
   812                 rset = execute(rql, kwargs, cachekey, build_descr=True)
   814             except NotImplementedError:
   813             except NotImplementedError:
   815                 self.critical('cant check rql expression, unsupported rql %s', rql)
   814                 self.critical('cant check rql expression, unsupported rql %s', rql)
   816                 if self.eid is not None:
   815                 if self.eid is not None:
   870             rql += ', X eid %(x)s'
   869             rql += ', X eid %(x)s'
   871         if 'U' in defined:
   870         if 'U' in defined:
   872             rql += ', U eid %(u)s'
   871             rql += ', U eid %(u)s'
   873         return rql
   872         return rql
   874 
   873 
   875     def check(self, session, eid=None, creating=False):
   874     def check(self, session, eid=None, creating=False, **kwargs):
   876         if 'X' in self.rqlst.defined_vars:
   875         if 'X' in self.rqlst.defined_vars:
   877             if eid is None:
   876             if eid is None:
   878                 if creating:
   877                 if creating:
   879                     return self._check(session, creating=True)
   878                     return self._check(session, creating=True, **kwargs)
   880                 return False
   879                 return False
   881             assert creating == False
   880             assert creating == False
   882             return self._check(session, x=eid)
   881             return self._check(session, x=eid, **kwargs)
   883         return self._check(session)
   882         return self._check(session, **kwargs)
   884 
   883 
   885 
   884 
   886 class RRQLExpression(RQLExpression):
   885 class RRQLExpression(RQLExpression):
   887     def __init__(self, expression, mainvars=None, eid=None):
   886     def __init__(self, expression, mainvars=None, eid=None):
   888         if mainvars is None:
   887         if mainvars is None: