author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 27 May 2009 15:00:38 +0200 | |
branch | stable |
changeset 1963 | c97c03082de9 |
parent 1742 | 25a765e756c4 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
"""core CubicWeb schema, but not necessary at bootstrap time |
2 |
||
3 |
:organization: Logilab |
|
1303 | 4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
||
9 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
10 |
class CWUser(WorkflowableEntityType): |
0 | 11 |
"""define a CubicWeb user""" |
629
59b6542f5729
provide a new WorkflowableEntityType base class (will be refactored later, maybe with schema interfaces)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
628
diff
changeset
|
12 |
meta = True # XXX backported from old times, shouldn't be there anymore |
0 | 13 |
permissions = { |
14 |
'read': ('managers', 'users', ERQLExpression('X identity U')), |
|
15 |
'add': ('managers',), |
|
16 |
'delete': ('managers',), |
|
17 |
'update': ('managers', ERQLExpression('X identity U, NOT U in_group G, G name "guests"'),), |
|
18 |
} |
|
19 |
||
20 |
login = String(required=True, unique=True, maxsize=64, |
|
21 |
description=_('unique identifier used to connect to the application')) |
|
22 |
upassword = Password(required=True) # password is a reserved word for mysql |
|
23 |
firstname = String(maxsize=64) |
|
24 |
surname = String(maxsize=64) |
|
25 |
last_login_time = Datetime(description=_('last connection date')) |
|
26 |
# allowing an email to be the primary email of multiple entities is necessary for |
|
1451 | 27 |
# test at least :-/ |
0 | 28 |
primary_email = SubjectRelation('EmailAddress', cardinality='??', |
29 |
description=_('email address to use for notification')) |
|
30 |
use_email = SubjectRelation('EmailAddress', cardinality='*?', composite='subject') |
|
31 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
32 |
in_group = SubjectRelation('CWGroup', cardinality='+*', |
0 | 33 |
constraints=[RQLConstraint('NOT O name "owners"')], |
34 |
description=_('groups grant permissions to the user')) |
|
35 |
||
36 |
||
37 |
class EmailAddress(MetaEntityType): |
|
38 |
"""an electronic mail address associated to a short alias""" |
|
39 |
permissions = { |
|
40 |
'read': ('managers', 'users', 'guests',), # XXX if P use_email X, U has_read_permission P |
|
41 |
'add': ('managers', 'users',), |
|
42 |
'delete': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')), |
|
43 |
'update': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')), |
|
44 |
} |
|
1451 | 45 |
|
0 | 46 |
alias = String(fulltextindexed=True, maxsize=56) |
1451 | 47 |
address = String(required=True, fulltextindexed=True, |
0 | 48 |
indexed=True, unique=True, maxsize=128) |
49 |
canonical = Boolean(default=False, |
|
50 |
description=_('when multiple addresses are equivalent \ |
|
51 |
(such as python-projects@logilab.org and python-projects@lists.logilab.org), set this \ |
|
52 |
to true on one of them which is the preferred form.')) |
|
53 |
identical_to = SubjectRelation('EmailAddress') |
|
54 |
||
55 |
class use_email(RelationType): |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1477
diff
changeset
|
56 |
""" """ |
0 | 57 |
permissions = { |
58 |
'read': ('managers', 'users', 'guests',), |
|
59 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
|
60 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
|
61 |
} |
|
62 |
fulltext_container = 'subject' |
|
63 |
||
64 |
class primary_email(RelationType): |
|
65 |
"""the prefered email""" |
|
66 |
permissions = use_email.permissions |
|
1451 | 67 |
|
0 | 68 |
class identical_to(RelationType): |
69 |
"""identical_to""" |
|
70 |
symetric = True |
|
71 |
permissions = { |
|
72 |
'read': ('managers', 'users', 'guests',), |
|
73 |
# XXX should have update permissions on both subject and object, |
|
74 |
# though by doing this we will probably have no way to add |
|
75 |
# this relation in the web ui. The easiest way to acheive this |
|
76 |
# is probably to be able to have "U has_update_permission O" as |
|
77 |
# RQLConstraint of the relation definition, though this is not yet |
|
78 |
# possible |
|
79 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
|
80 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
|
81 |
} |
|
82 |
||
83 |
class in_group(MetaRelationType): |
|
84 |
"""core relation indicating a user's groups""" |
|
85 |
meta = False |
|
1451 | 86 |
|
0 | 87 |
class owned_by(MetaRelationType): |
88 |
"""core relation indicating owners of an entity. This relation |
|
89 |
implicitly put the owner into the owners group for the entity |
|
90 |
""" |
|
91 |
permissions = { |
|
92 |
'read': ('managers', 'users', 'guests'), |
|
1451 | 93 |
'add': ('managers', RRQLExpression('S owned_by U'),), |
0 | 94 |
'delete': ('managers', RRQLExpression('S owned_by U'),), |
95 |
} |
|
96 |
# 0..n cardinality for entities created by internal session (no attached user) |
|
97 |
# and to support later deletion of a user which has created some entities |
|
98 |
cardinality = '**' |
|
99 |
subject = '**' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
100 |
object = 'CWUser' |
1451 | 101 |
|
0 | 102 |
class created_by(MetaRelationType): |
103 |
"""core relation indicating the original creator of an entity""" |
|
104 |
permissions = { |
|
105 |
'read': ('managers', 'users', 'guests'), |
|
106 |
'add': ('managers',), |
|
107 |
'delete': ('managers',), |
|
108 |
} |
|
109 |
# 0..1 cardinality for entities created by internal session (no attached user) |
|
110 |
# and to support later deletion of a user which has created some entities |
|
1451 | 111 |
cardinality = '?*' |
0 | 112 |
subject = '**' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
113 |
object = 'CWUser' |
0 | 114 |
|
1451 | 115 |
|
0 | 116 |
class creation_date(MetaAttributeRelationType): |
117 |
"""creation time of an entity""" |
|
118 |
cardinality = '11' |
|
119 |
subject = '**' |
|
120 |
object = 'Datetime' |
|
121 |
||
122 |
class modification_date(MetaAttributeRelationType): |
|
123 |
"""latest modification time of an entity""" |
|
124 |
cardinality = '11' |
|
125 |
subject = '**' |
|
126 |
object = 'Datetime' |
|
127 |
||
128 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
129 |
class CWProperty(EntityType): |
0 | 130 |
"""used for cubicweb configuration. Once a property has been created you |
131 |
can't change the key. |
|
132 |
""" |
|
133 |
permissions = { |
|
134 |
'read': ('managers', 'users', 'guests'), |
|
135 |
'add': ('managers', 'users',), |
|
136 |
'update': ('managers', 'owners',), |
|
137 |
'delete': ('managers', 'owners',), |
|
138 |
} |
|
139 |
meta = True |
|
140 |
# key is a reserved word for mysql |
|
141 |
pkey = String(required=True, internationalizable=True, maxsize=256, |
|
142 |
description=_('defines what\'s the property is applied for. ' |
|
143 |
'You must select this first to be able to set ' |
|
144 |
'value')) |
|
145 |
value = String(internationalizable=True, maxsize=256) |
|
1451 | 146 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
147 |
for_user = SubjectRelation('CWUser', cardinality='?*', composite='object', |
0 | 148 |
description=_('user for which this property is ' |
149 |
'applying. If this relation is not ' |
|
150 |
'set, the property is considered as' |
|
151 |
' a global property')) |
|
152 |
||
153 |
||
154 |
class for_user(MetaRelationType): |
|
155 |
"""link a property to the user which want this property customization. Unless |
|
156 |
you're a site manager, this relation will be handled automatically. |
|
157 |
""" |
|
158 |
permissions = { |
|
159 |
'read': ('managers', 'users', 'guests'), |
|
160 |
'add': ('managers',), |
|
161 |
'delete': ('managers',), |
|
162 |
} |
|
163 |
inlined = True |
|
164 |
||
165 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
166 |
class CWPermission(MetaEntityType): |
0 | 167 |
"""entity type that may be used to construct some advanced security configuration |
168 |
""" |
|
169 |
name = String(required=True, indexed=True, internationalizable=True, maxsize=100, |
|
170 |
description=_('name or identifier of the permission')) |
|
171 |
label = String(required=True, internationalizable=True, maxsize=100, |
|
172 |
description=_('distinct label to distinguate between other permission entity of the same name')) |
|
1451 | 173 |
require_group = SubjectRelation('CWGroup', |
0 | 174 |
description=_('groups to which the permission is granted')) |
175 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
176 |
# explicitly add X require_permission CWPermission for each entity that should have |
0 | 177 |
# configurable security |
178 |
class require_permission(RelationType): |
|
179 |
"""link a permission to the entity. This permission should be used in the |
|
180 |
security definition of the entity's type to be useful. |
|
181 |
""" |
|
182 |
permissions = { |
|
183 |
'read': ('managers', 'users', 'guests'), |
|
184 |
'add': ('managers',), |
|
185 |
'delete': ('managers',), |
|
186 |
} |
|
1451 | 187 |
|
0 | 188 |
class require_group(MetaRelationType): |
189 |
"""used to grant a permission to a group""" |
|
190 |
permissions = { |
|
191 |
'read': ('managers', 'users', 'guests'), |
|
192 |
'add': ('managers',), |
|
193 |
'delete': ('managers',), |
|
194 |
} |
|
195 |
||
1451 | 196 |
|
0 | 197 |
class see_also(RelationType): |
198 |
"""generic relation to link one entity to another""" |
|
199 |
symetric = True |
|
200 |
||
1477 | 201 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
202 |
class CWCache(MetaEntityType): |
59
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
203 |
"""a simple cache entity characterized by a name and |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
204 |
a validity date. |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
205 |
|
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
206 |
The target application is responsible for updating timestamp |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
207 |
when necessary to invalidate the cache (typically in hooks). |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
208 |
|
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
209 |
Also, checkout the AppRsetObject.get_cache() method. |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
210 |
""" |
6
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
211 |
permissions = { |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
212 |
'read': ('managers', 'users', 'guests'), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
213 |
'add': ('managers',), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
214 |
'update': ('managers', 'users',), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
215 |
'delete': ('managers',), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
216 |
} |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
217 |
|
1445
d3c9b075ceb7
set a size constraint on ECache's title
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1281
diff
changeset
|
218 |
name = String(required=True, unique=True, indexed=True, maxsize=128, |
0 | 219 |
description=_('name of the cache')) |
220 |
timestamp = Datetime(default='NOW') |