7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from cubicweb.schema import format_constraint |
9 from cubicweb.schema import format_constraint |
10 |
10 |
11 |
11 |
12 class EUser(WorkflowableEntityType): |
12 class CWUser(WorkflowableEntityType): |
13 """define a CubicWeb user""" |
13 """define a CubicWeb user""" |
14 meta = True # XXX backported from old times, shouldn't be there anymore |
14 meta = True # XXX backported from old times, shouldn't be there anymore |
15 permissions = { |
15 permissions = { |
16 'read': ('managers', 'users', ERQLExpression('X identity U')), |
16 'read': ('managers', 'users', ERQLExpression('X identity U')), |
17 'add': ('managers',), |
17 'add': ('managers',), |
29 # test at least :-/ |
29 # test at least :-/ |
30 primary_email = SubjectRelation('EmailAddress', cardinality='??', |
30 primary_email = SubjectRelation('EmailAddress', cardinality='??', |
31 description=_('email address to use for notification')) |
31 description=_('email address to use for notification')) |
32 use_email = SubjectRelation('EmailAddress', cardinality='*?', composite='subject') |
32 use_email = SubjectRelation('EmailAddress', cardinality='*?', composite='subject') |
33 |
33 |
34 in_group = SubjectRelation('EGroup', cardinality='+*', |
34 in_group = SubjectRelation('CWGroup', cardinality='+*', |
35 constraints=[RQLConstraint('NOT O name "owners"')], |
35 constraints=[RQLConstraint('NOT O name "owners"')], |
36 description=_('groups grant permissions to the user')) |
36 description=_('groups grant permissions to the user')) |
37 |
37 |
38 |
38 |
39 class EmailAddress(MetaEntityType): |
39 class EmailAddress(MetaEntityType): |
97 } |
97 } |
98 # 0..n cardinality for entities created by internal session (no attached user) |
98 # 0..n cardinality for entities created by internal session (no attached user) |
99 # and to support later deletion of a user which has created some entities |
99 # and to support later deletion of a user which has created some entities |
100 cardinality = '**' |
100 cardinality = '**' |
101 subject = '**' |
101 subject = '**' |
102 object = 'EUser' |
102 object = 'CWUser' |
103 |
103 |
104 class created_by(MetaRelationType): |
104 class created_by(MetaRelationType): |
105 """core relation indicating the original creator of an entity""" |
105 """core relation indicating the original creator of an entity""" |
106 permissions = { |
106 permissions = { |
107 'read': ('managers', 'users', 'guests'), |
107 'read': ('managers', 'users', 'guests'), |
125 """latest modification time of an entity""" |
125 """latest modification time of an entity""" |
126 cardinality = '11' |
126 cardinality = '11' |
127 subject = '**' |
127 subject = '**' |
128 object = 'Datetime' |
128 object = 'Datetime' |
129 |
129 |
130 class EProperty(EntityType): |
130 class CWProperty(EntityType): |
131 """used for cubicweb configuration. Once a property has been created you |
131 """used for cubicweb configuration. Once a property has been created you |
132 can't change the key. |
132 can't change the key. |
133 """ |
133 """ |
134 permissions = { |
134 permissions = { |
135 'read': ('managers', 'users', 'guests'), |
135 'read': ('managers', 'users', 'guests'), |
143 description=_('defines what\'s the property is applied for. ' |
143 description=_('defines what\'s the property is applied for. ' |
144 'You must select this first to be able to set ' |
144 'You must select this first to be able to set ' |
145 'value')) |
145 'value')) |
146 value = String(internationalizable=True, maxsize=256) |
146 value = String(internationalizable=True, maxsize=256) |
147 |
147 |
148 for_user = SubjectRelation('EUser', cardinality='?*', composite='object', |
148 for_user = SubjectRelation('CWUser', cardinality='?*', composite='object', |
149 description=_('user for which this property is ' |
149 description=_('user for which this property is ' |
150 'applying. If this relation is not ' |
150 'applying. If this relation is not ' |
151 'set, the property is considered as' |
151 'set, the property is considered as' |
152 ' a global property')) |
152 ' a global property')) |
153 |
153 |
162 'delete': ('managers',), |
162 'delete': ('managers',), |
163 } |
163 } |
164 inlined = True |
164 inlined = True |
165 |
165 |
166 |
166 |
167 class EPermission(MetaEntityType): |
167 class CWPermission(MetaEntityType): |
168 """entity type that may be used to construct some advanced security configuration |
168 """entity type that may be used to construct some advanced security configuration |
169 """ |
169 """ |
170 name = String(required=True, indexed=True, internationalizable=True, maxsize=100, |
170 name = String(required=True, indexed=True, internationalizable=True, maxsize=100, |
171 description=_('name or identifier of the permission')) |
171 description=_('name or identifier of the permission')) |
172 label = String(required=True, internationalizable=True, maxsize=100, |
172 label = String(required=True, internationalizable=True, maxsize=100, |
173 description=_('distinct label to distinguate between other permission entity of the same name')) |
173 description=_('distinct label to distinguate between other permission entity of the same name')) |
174 require_group = SubjectRelation('EGroup', |
174 require_group = SubjectRelation('CWGroup', |
175 description=_('groups to which the permission is granted')) |
175 description=_('groups to which the permission is granted')) |
176 |
176 |
177 # explicitly add X require_permission EPermission for each entity that should have |
177 # explicitly add X require_permission CWPermission for each entity that should have |
178 # configurable security |
178 # configurable security |
179 class require_permission(RelationType): |
179 class require_permission(RelationType): |
180 """link a permission to the entity. This permission should be used in the |
180 """link a permission to the entity. This permission should be used in the |
181 security definition of the entity's type to be useful. |
181 security definition of the entity's type to be useful. |
182 """ |
182 """ |
197 |
197 |
198 class see_also(RelationType): |
198 class see_also(RelationType): |
199 """generic relation to link one entity to another""" |
199 """generic relation to link one entity to another""" |
200 symetric = True |
200 symetric = True |
201 |
201 |
202 class ECache(MetaEntityType): |
202 class CWCache(MetaEntityType): |
203 """a simple cache entity characterized by a name and |
203 """a simple cache entity characterized by a name and |
204 a validity date. |
204 a validity date. |
205 |
205 |
206 The target application is responsible for updating timestamp |
206 The target application is responsible for updating timestamp |
207 when necessary to invalidate the cache (typically in hooks). |
207 when necessary to invalidate the cache (typically in hooks). |