Add a global variable for default EntityType permissions

Following what is done for relations and attributes.

Closes #245548.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changeset1092858acdb7
branchdefault
phasepublic
hiddenno
parent revision#2027fae22227 [schema] properly implement != comparison
child revision#616c2bd144ea buildobjs: allow defining attributes by subclassing RelationDefinition again
files modified by this revision
__init__.py
buildobjs.py
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1399884083 -7200
# Mon May 12 10:41:23 2014 +0200
# Node ID 1092858acdb71350bf13f919a45e422fbc4532f6
# Parent 2027fae222272615dae307db78fc43102fc20ba3
Add a global variable for default EntityType permissions

Following what is done for relations and attributes.

Closes #245548.

diff --git a/__init__.py b/__init__.py
@@ -42,11 +42,15 @@
1                    ))
2 
3  # base groups used in permissions
4  BASE_GROUPS = set((_('managers'), _('users'), _('guests'), _('owners')))
5 
6 -# default permissions for relations and attributes
7 +# default permissions for entity types, relations and attributes
8 +DEFAULT_ETYPEPERMS = {'read': ('managers', 'users', 'guests',),
9 +                      'update': ('managers', 'owners',),
10 +                      'delete': ('managers', 'owners'),
11 +                      'add': ('managers', 'users',)}
12  DEFAULT_RELPERMS = {'read': ('managers', 'users', 'guests',),
13                      'delete': ('managers', 'users'),
14                      'add': ('managers', 'users',)}
15  DEFAULT_ATTRPERMS = {'read': ('managers', 'users', 'guests',),
16                       'add': ('managers', 'users'),
diff --git a/buildobjs.py b/buildobjs.py
@@ -26,11 +26,12 @@
17 
18  from logilab.common import attrdict
19  from logilab.common.decorators import iclassmethod
20 
21  from yams import (BASE_TYPES, MARKER, BadSchemaDefinition, KNOWN_METAATTRIBUTES,
22 -                  DEFAULT_RELPERMS, DEFAULT_ATTRPERMS, DEFAULT_COMPUTED_ATTRPERMS)
23 +                  DEFAULT_ETYPEPERMS, DEFAULT_RELPERMS, DEFAULT_ATTRPERMS,
24 +                  DEFAULT_COMPUTED_ATTRPERMS)
25  from yams.constraints import (SizeConstraint, UniqueConstraint,
26                                StaticVocabularyConstraint, FORMAT_CONSTRAINT)
27  from yams.schema import RelationDefinitionSchema
28 
29  PACKAGE = '<builtin>' # will be modified by the yams'reader when schema is
@@ -114,11 +115,10 @@
30      for etype in BASE_TYPES:
31          edef = EntityType(name=etype)
32          schema.add_entity_type(edef)
33 
34 
35 -
36  # first class schema definition objects #######################################
37 
38  class autopackage(type):
39      def __new__(mcs, name, bases, classdict):
40          classdict['package'] = PACKAGE
@@ -419,16 +419,11 @@
41      #:  .. automethod:: EntityType.insert_relation_after
42      #:  .. automethod:: EntityType.remove_relation
43      #:  .. automethod:: EntityType.get_relation
44      #:  .. automethod:: EntityType.get_relations
45 
46 -    __permissions__ = {
47 -        'read': ('managers', 'users', 'guests',),
48 -        'update': ('managers', 'owners',),
49 -        'delete': ('managers', 'owners'),
50 -        'add': ('managers', 'users',)
51 -        }
52 +    __permissions__ = DEFAULT_ETYPEPERMS
53 
54      def __init__(self, name=None, **kwargs):
55          super(EntityType, self).__init__(name)
56          _check_kwargs(kwargs, ETYPE_PROPERTIES)
57          self.__dict__.update(kwargs)