schemas/__init__.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """some constants and classes to define schema permissions"""
       
    19 
       
    20 __docformat__ = "restructuredtext en"
       
    21 
       
    22 from cubicweb.schema import RO_REL_PERMS, RO_ATTR_PERMS, \
       
    23      PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, \
       
    24      ERQLExpression, RRQLExpression
       
    25 
       
    26 # permissions for "meta" entity type (readable by anyone, can only be
       
    27 # added/deleted by managers)
       
    28 META_ETYPE_PERMS = PUB_SYSTEM_ENTITY_PERMS # XXX deprecates
       
    29 # permissions for "meta" relation type (readable by anyone, can only be
       
    30 # added/deleted by managers)
       
    31 META_RTYPE_PERMS = PUB_SYSTEM_REL_PERMS # XXX deprecates
       
    32 # permissions for relation type that should only set by hooks using unsafe
       
    33 # execute, readable by anyone
       
    34 HOOKS_RTYPE_PERMS = RO_REL_PERMS # XXX deprecates
       
    35 
       
    36 
       
    37 from logilab.common.modutils import LazyObject
       
    38 from logilab.common.deprecation import deprecated
       
    39 class MyLazyObject(LazyObject):
       
    40 
       
    41     def _getobj(self):
       
    42         try:
       
    43             return super(MyLazyObject, self)._getobj()
       
    44         except ImportError:
       
    45             raise ImportError('In cubicweb 3.14, function %s has been moved to '
       
    46                               'cube localperms. Install it first.' % self.obj)
       
    47 
       
    48 for name in ('xperm', 'xexpr', 'xrexpr', 'xorexpr', 'sexpr', 'restricted_sexpr',
       
    49              'restricted_oexpr', 'oexpr', 'relxperm', 'relxexpr', '_perm'):
       
    50     msg = '[3.14] import %s from cubes.localperms' % name
       
    51     globals()[name] = deprecated(msg, name=name, doc='deprecated')(MyLazyObject('cubes.localperms', name))