schema.py
changeset 10612 84468b90e9c1
parent 10609 e2d8e81bfe68
child 10653 42c5bd7286b7
equal deleted inserted replaced
10611:f4dec0cca9a1 10612:84468b90e9c1
    24 import re
    24 import re
    25 from os.path import join, basename
    25 from os.path import join, basename
    26 from logging import getLogger
    26 from logging import getLogger
    27 from warnings import warn
    27 from warnings import warn
    28 
    28 
       
    29 from six import string_types
    29 from six.moves import range
    30 from six.moves import range
    30 
    31 
    31 from logilab.common import tempattr
    32 from logilab.common import tempattr
    32 from logilab.common.decorators import cached, clear_cache, monkeypatch, cachedproperty
    33 from logilab.common.decorators import cached, clear_cache, monkeypatch, cachedproperty
    33 from logilab.common.logging_ext import set_log_methods
    34 from logilab.common.logging_ext import set_log_methods
   205         :param mainvars: names of the variables being selected.
   206         :param mainvars: names of the variables being selected.
   206 
   207 
   207         """
   208         """
   208         self.eid = eid # eid of the entity representing this rql expression
   209         self.eid = eid # eid of the entity representing this rql expression
   209         assert mainvars, 'bad mainvars %s' % mainvars
   210         assert mainvars, 'bad mainvars %s' % mainvars
   210         if isinstance(mainvars, basestring):
   211         if isinstance(mainvars, string_types):
   211             mainvars = set(splitstrip(mainvars))
   212             mainvars = set(splitstrip(mainvars))
   212         elif not isinstance(mainvars, set):
   213         elif not isinstance(mainvars, set):
   213             mainvars = set(mainvars)
   214             mainvars = set(mainvars)
   214         self.mainvars = mainvars
   215         self.mainvars = mainvars
   215         self.expression = normalize_expression(expression)
   216         self.expression = normalize_expression(expression)
   577     :return: names of the groups with the given permission
   578     :return: names of the groups with the given permission
   578     """
   579     """
   579     assert action in self.ACTIONS, action
   580     assert action in self.ACTIONS, action
   580     #assert action in self._groups, '%s %s' % (self, action)
   581     #assert action in self._groups, '%s %s' % (self, action)
   581     try:
   582     try:
   582         return frozenset(g for g in self.permissions[action] if isinstance(g, basestring))
   583         return frozenset(g for g in self.permissions[action] if isinstance(g, string_types))
   583     except KeyError:
   584     except KeyError:
   584         return ()
   585         return ()
   585 PermissionMixIn.get_groups = get_groups
   586 PermissionMixIn.get_groups = get_groups
   586 
   587 
   587 @cached
   588 @cached
   596     :return: the rql expressions with the given permission
   597     :return: the rql expressions with the given permission
   597     """
   598     """
   598     assert action in self.ACTIONS, action
   599     assert action in self.ACTIONS, action
   599     #assert action in self._rqlexprs, '%s %s' % (self, action)
   600     #assert action in self._rqlexprs, '%s %s' % (self, action)
   600     try:
   601     try:
   601         return tuple(g for g in self.permissions[action] if not isinstance(g, basestring))
   602         return tuple(g for g in self.permissions[action] if not isinstance(g, string_types))
   602     except KeyError:
   603     except KeyError:
   603         return ()
   604         return ()
   604 PermissionMixIn.get_rqlexprs = get_rqlexprs
   605 PermissionMixIn.get_rqlexprs = get_rqlexprs
   605 
   606 
   606 orig_set_action_permissions = PermissionMixIn.set_action_permissions
   607 orig_set_action_permissions = PermissionMixIn.set_action_permissions