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