1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
88 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig')) |
88 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig')) |
89 |
89 |
90 |
90 |
91 _LOGGER = getLogger('cubicweb.schemaloader') |
91 _LOGGER = getLogger('cubicweb.schemaloader') |
92 |
92 |
93 # schema entities created from serialized schema have an eid rproperty |
93 # entity and relation schema created from serialized schema have an eid |
94 ybo.ETYPE_PROPERTIES += ('eid',) |
94 ybo.ETYPE_PROPERTIES += ('eid',) |
95 ybo.RTYPE_PROPERTIES += ('eid',) |
95 ybo.RTYPE_PROPERTIES += ('eid',) |
96 ybo.RDEF_PROPERTIES += ('eid',) |
|
97 |
|
98 |
96 |
99 PUB_SYSTEM_ENTITY_PERMS = { |
97 PUB_SYSTEM_ENTITY_PERMS = { |
100 'read': ('managers', 'users', 'guests',), |
98 'read': ('managers', 'users', 'guests',), |
101 'add': ('managers',), |
99 'add': ('managers',), |
102 'delete': ('managers',), |
100 'delete': ('managers',), |
294 raise Unauthorized(action, str(self)) |
292 raise Unauthorized(action, str(self)) |
295 PermissionMixIn.check_perm = check_perm |
293 PermissionMixIn.check_perm = check_perm |
296 |
294 |
297 |
295 |
298 RelationDefinitionSchema._RPROPERTIES['eid'] = None |
296 RelationDefinitionSchema._RPROPERTIES['eid'] = None |
|
297 # remember rproperties defined at this point. Others will have to be serialized in |
|
298 # CWAttribute.extra_props |
|
299 KNOWN_RPROPERTIES = RelationDefinitionSchema.ALL_PROPERTIES() |
299 |
300 |
300 def rql_expression(self, expression, mainvars=None, eid=None): |
301 def rql_expression(self, expression, mainvars=None, eid=None): |
301 """rql expression factory""" |
302 """rql expression factory""" |
302 if self.rtype.final: |
303 if self.rtype.final: |
303 return ERQLExpression(expression, mainvars, eid) |
304 return ERQLExpression(expression, mainvars, eid) |
698 def __str__(self): |
699 def __str__(self): |
699 return self.full_rql |
700 return self.full_rql |
700 def __repr__(self): |
701 def __repr__(self): |
701 return '%s(%s)' % (self.__class__.__name__, self.full_rql) |
702 return '%s(%s)' % (self.__class__.__name__, self.full_rql) |
702 |
703 |
703 def __cmp__(self, other): |
704 def __lt__(self, other): |
704 if hasattr(other, 'expression'): |
705 if hasattr(other, 'expression'): |
705 return cmp(other.expression, self.expression) |
706 return self.expression < other.expression |
706 return -1 |
707 return True |
|
708 |
|
709 def __eq__(self, other): |
|
710 if hasattr(other, 'expression'): |
|
711 return self.expression == other.expression |
|
712 return False |
707 |
713 |
708 def __deepcopy__(self, memo): |
714 def __deepcopy__(self, memo): |
709 return self.__class__(self.expression, self.mainvars) |
715 return self.__class__(self.expression, self.mainvars) |
710 def __getstate__(self): |
716 def __getstate__(self): |
711 return (self.expression, self.mainvars) |
717 return (self.expression, self.mainvars) |