3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 |
8 __docformat__ = "restructuredtext en" |
9 from cubicweb.schema import RichString |
9 _ = unicode |
10 |
10 |
|
11 from yams.buildobjs import (EntityType, RelationType, SubjectRelation, |
|
12 ObjectRelation, String, Boolean, Int) |
|
13 from cubicweb.schema import RichString, RQLConstraint |
|
14 from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS |
11 |
15 |
12 # not restricted since as "is" is handled as other relations, guests need |
16 # not restricted since as "is" is handled as other relations, guests need |
13 # access to this |
17 # access to this |
14 class CWEType(MetaEntityType): |
18 class CWEType(EntityType): |
15 """define an entity type, used to build the application schema""" |
19 """define an entity type, used to build the application schema""" |
|
20 permissions = META_ETYPE_PERMS |
16 name = String(required=True, indexed=True, internationalizable=True, |
21 name = String(required=True, indexed=True, internationalizable=True, |
17 unique=True, maxsize=64) |
22 unique=True, maxsize=64) |
18 description = RichString(internationalizable=True, |
23 description = RichString(internationalizable=True, |
19 description=_('semantic description of this entity type')) |
24 description=_('semantic description of this entity type')) |
20 # necessary to filter using RQL |
25 # necessary to filter using RQL |
21 final = Boolean(description=_('automatic')) |
26 final = Boolean(description=_('automatic')) |
22 |
27 |
23 |
28 |
24 class CWRType(MetaEntityType): |
29 class CWRType(EntityType): |
25 """define a relation type, used to build the application schema""" |
30 """define a relation type, used to build the application schema""" |
|
31 permissions = META_ETYPE_PERMS |
26 name = String(required=True, indexed=True, internationalizable=True, |
32 name = String(required=True, indexed=True, internationalizable=True, |
27 unique=True, maxsize=64) |
33 unique=True, maxsize=64) |
28 description = RichString(internationalizable=True, |
34 description = RichString(internationalizable=True, |
29 description=_('semantic description of this relation type')) |
35 description=_('semantic description of this relation type')) |
30 symetric = Boolean(description=_('is this relation equivalent in both direction ?')) |
36 symetric = Boolean(description=_('is this relation equivalent in both direction ?')) |
34 vocabulary=('', _('subject'), _('object')), |
40 vocabulary=('', _('subject'), _('object')), |
35 maxsize=8, default=None) |
41 maxsize=8, default=None) |
36 final = Boolean(description=_('automatic')) |
42 final = Boolean(description=_('automatic')) |
37 |
43 |
38 |
44 |
39 class CWAttribute(MetaEntityType): |
45 class CWAttribute(EntityType): |
40 """define a final relation: link a final relation type from a non final |
46 """define a final relation: link a final relation type from a non final |
41 entity to a final entity type. |
47 entity to a final entity type. |
42 |
48 |
43 used to build the application schema |
49 used to build the application schema |
44 """ |
50 """ |
|
51 permissions = META_ETYPE_PERMS |
45 relation_type = SubjectRelation('CWRType', cardinality='1*', |
52 relation_type = SubjectRelation('CWRType', cardinality='1*', |
46 constraints=[RQLConstraint('O final TRUE')], |
53 constraints=[RQLConstraint('O final TRUE')], |
47 composite='object') |
54 composite='object') |
48 from_entity = SubjectRelation('CWEType', cardinality='1*', |
55 from_entity = SubjectRelation('CWEType', cardinality='1*', |
49 constraints=[RQLConstraint('O final FALSE')], |
56 constraints=[RQLConstraint('O final FALSE')], |
70 CARDINALITY_VOCAB = [_('?*'), _('1*'), _('+*'), _('**'), |
77 CARDINALITY_VOCAB = [_('?*'), _('1*'), _('+*'), _('**'), |
71 _('?+'), _('1+'), _('++'), _('*+'), |
78 _('?+'), _('1+'), _('++'), _('*+'), |
72 _('?1'), _('11'), _('+1'), _('*1'), |
79 _('?1'), _('11'), _('+1'), _('*1'), |
73 _('??'), _('1?'), _('+?'), _('*?')] |
80 _('??'), _('1?'), _('+?'), _('*?')] |
74 |
81 |
75 class CWRelation(MetaEntityType): |
82 class CWRelation(EntityType): |
76 """define a non final relation: link a non final relation type from a non |
83 """define a non final relation: link a non final relation type from a non |
77 final entity to a non final entity type. |
84 final entity to a non final entity type. |
78 |
85 |
79 used to build the application schema |
86 used to build the application schema |
80 """ |
87 """ |
|
88 permissions = META_ETYPE_PERMS |
81 relation_type = SubjectRelation('CWRType', cardinality='1*', |
89 relation_type = SubjectRelation('CWRType', cardinality='1*', |
82 constraints=[RQLConstraint('O final FALSE')], |
90 constraints=[RQLConstraint('O final FALSE')], |
83 composite='object') |
91 composite='object') |
84 from_entity = SubjectRelation('CWEType', cardinality='1*', |
92 from_entity = SubjectRelation('CWEType', cardinality='1*', |
85 constraints=[RQLConstraint('O final FALSE')], |
93 constraints=[RQLConstraint('O final FALSE')], |
104 description = RichString(internationalizable=True, |
112 description = RichString(internationalizable=True, |
105 description=_('semantic description of this relation')) |
113 description=_('semantic description of this relation')) |
106 |
114 |
107 |
115 |
108 # not restricted since it has to be read when checking allowed transitions |
116 # not restricted since it has to be read when checking allowed transitions |
109 class RQLExpression(MetaEntityType): |
117 class RQLExpression(EntityType): |
110 """define a rql expression used to define permissions""" |
118 """define a rql expression used to define permissions""" |
|
119 permissions = META_ETYPE_PERMS |
111 exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression']) |
120 exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression']) |
112 mainvars = String(maxsize=8, |
121 mainvars = String(maxsize=8, |
113 description=_('name of the main variables which should be ' |
122 description=_('name of the main variables which should be ' |
114 'used in the selection if necessary (comma ' |
123 'used in the selection if necessary (comma ' |
115 'separated)')) |
124 'separated)')) |
130 description=_('rql expression allowing to delete entities/relations of this type')) |
139 description=_('rql expression allowing to delete entities/relations of this type')) |
131 update_permission = ObjectRelation('CWEType', cardinality='*?', composite='subject', |
140 update_permission = ObjectRelation('CWEType', cardinality='*?', composite='subject', |
132 description=_('rql expression allowing to update entities of this type')) |
141 description=_('rql expression allowing to update entities of this type')) |
133 |
142 |
134 |
143 |
135 class CWConstraint(MetaEntityType): |
144 class CWConstraint(EntityType): |
136 """define a schema constraint""" |
145 """define a schema constraint""" |
|
146 permissions = META_ETYPE_PERMS |
137 cstrtype = SubjectRelation('CWConstraintType', cardinality='1*') |
147 cstrtype = SubjectRelation('CWConstraintType', cardinality='1*') |
138 value = String(description=_('depends on the constraint type')) |
148 value = String(description=_('depends on the constraint type')) |
139 |
149 |
140 |
150 |
141 class CWConstraintType(MetaEntityType): |
151 class CWConstraintType(EntityType): |
142 """define a schema constraint type""" |
152 """define a schema constraint type""" |
|
153 permissions = META_ETYPE_PERMS |
143 name = String(required=True, indexed=True, internationalizable=True, |
154 name = String(required=True, indexed=True, internationalizable=True, |
144 unique=True, maxsize=64) |
155 unique=True, maxsize=64) |
145 |
156 |
146 |
157 |
147 # not restricted since it has to be read when checking allowed transitions |
158 # not restricted since it has to be read when checking allowed transitions |
148 class CWGroup(MetaEntityType): |
159 class CWGroup(EntityType): |
149 """define a CubicWeb users group""" |
160 """define a CubicWeb users group""" |
|
161 permissions = META_ETYPE_PERMS |
150 name = String(required=True, indexed=True, internationalizable=True, |
162 name = String(required=True, indexed=True, internationalizable=True, |
151 unique=True, maxsize=64) |
163 unique=True, maxsize=64) |
152 |
164 |
153 read_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='+*', |
165 read_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='+*', |
154 description=_('groups allowed to read entities/relations of this type')) |
166 description=_('groups allowed to read entities/relations of this type')) |
159 update_permission = ObjectRelation('CWEType', |
171 update_permission = ObjectRelation('CWEType', |
160 description=_('groups allowed to update entities of this type')) |
172 description=_('groups allowed to update entities of this type')) |
161 |
173 |
162 |
174 |
163 |
175 |
164 class relation_type(MetaRelationType): |
176 class relation_type(RelationType): |
165 """link a relation definition to its relation type""" |
177 """link a relation definition to its relation type""" |
166 inlined = True |
178 permissions = META_RTYPE_PERMS |
167 class from_entity(MetaRelationType): |
179 inlined = True |
|
180 |
|
181 class from_entity(RelationType): |
168 """link a relation definition to its subject entity type""" |
182 """link a relation definition to its subject entity type""" |
169 inlined = True |
183 permissions = META_RTYPE_PERMS |
170 class to_entity(MetaRelationType): |
184 inlined = True |
|
185 |
|
186 class to_entity(RelationType): |
171 """link a relation definition to its object entity type""" |
187 """link a relation definition to its object entity type""" |
172 inlined = True |
188 permissions = META_RTYPE_PERMS |
173 class constrained_by(MetaRelationType): |
189 inlined = True |
|
190 |
|
191 class constrained_by(RelationType): |
174 """constraints applying on this relation""" |
192 """constraints applying on this relation""" |
175 |
193 permissions = META_RTYPE_PERMS |
176 class cstrtype(MetaRelationType): |
194 |
|
195 class cstrtype(RelationType): |
177 """constraint factory""" |
196 """constraint factory""" |
178 inlined = True |
197 permissions = META_RTYPE_PERMS |
179 |
198 inlined = True |
180 class read_permission(MetaRelationType): |
199 |
|
200 class read_permission(RelationType): |
181 """core relation giving to a group the permission to read an entity or |
201 """core relation giving to a group the permission to read an entity or |
182 relation type |
202 relation type |
183 """ |
203 """ |
184 class add_permission(MetaRelationType): |
204 permissions = META_RTYPE_PERMS |
|
205 |
|
206 class add_permission(RelationType): |
185 """core relation giving to a group the permission to add an entity or |
207 """core relation giving to a group the permission to add an entity or |
186 relation type |
208 relation type |
187 """ |
209 """ |
188 class delete_permission(MetaRelationType): |
210 permissions = META_RTYPE_PERMS |
|
211 |
|
212 class delete_permission(RelationType): |
189 """core relation giving to a group the permission to delete an entity or |
213 """core relation giving to a group the permission to delete an entity or |
190 relation type |
214 relation type |
191 """ |
215 """ |
192 class update_permission(MetaRelationType): |
216 permissions = META_RTYPE_PERMS |
|
217 |
|
218 class update_permission(RelationType): |
193 """core relation giving to a group the permission to update an entity type |
219 """core relation giving to a group the permission to update an entity type |
194 """ |
220 """ |
195 |
221 permissions = META_RTYPE_PERMS |
196 |
222 |
197 class is_(MetaRelationType): |
223 |
|
224 class is_(RelationType): |
198 """core relation indicating the type of an entity |
225 """core relation indicating the type of an entity |
199 """ |
226 """ |
200 name = 'is' |
227 name = 'is' |
201 # don't explicitly set composite here, this is handled anyway |
228 # don't explicitly set composite here, this is handled anyway |
202 #composite = 'object' |
229 #composite = 'object' |