author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 23 Sep 2010 10:46:38 +0200 | |
branch | stable |
changeset 6314 | b233cc448bdd |
parent 5896 | 67683b7e591a |
child 6427 | c8a5ac2d1eaa |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4759
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5896 | 18 |
"""core CubicWeb schema, but not necessary at bootstrap time""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
21 |
_ = unicode |
0 | 22 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
23 |
from yams.buildobjs import (EntityType, RelationType, SubjectRelation, |
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4590
diff
changeset
|
24 |
String, Datetime, Password) |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
25 |
from cubicweb.schema import ( |
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
26 |
RQLConstraint, WorkflowableEntityType, ERQLExpression, RRQLExpression, |
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
27 |
PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, PUB_SYSTEM_ATTR_PERMS) |
0 | 28 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
29 |
class CWUser(WorkflowableEntityType): |
0 | 30 |
"""define a CubicWeb user""" |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
31 |
__permissions__ = { |
0 | 32 |
'read': ('managers', 'users', ERQLExpression('X identity U')), |
33 |
'add': ('managers',), |
|
34 |
'delete': ('managers',), |
|
35 |
'update': ('managers', ERQLExpression('X identity U, NOT U in_group G, G name "guests"'),), |
|
36 |
} |
|
37 |
||
38 |
login = String(required=True, unique=True, maxsize=64, |
|
39 |
description=_('unique identifier used to connect to the application')) |
|
40 |
upassword = Password(required=True) # password is a reserved word for mysql |
|
41 |
firstname = String(maxsize=64) |
|
42 |
surname = String(maxsize=64) |
|
43 |
last_login_time = Datetime(description=_('last connection date')) |
|
44 |
# allowing an email to be the primary email of multiple entities is necessary for |
|
1451 | 45 |
# test at least :-/ |
0 | 46 |
primary_email = SubjectRelation('EmailAddress', cardinality='??', |
47 |
description=_('email address to use for notification')) |
|
48 |
use_email = SubjectRelation('EmailAddress', cardinality='*?', composite='subject') |
|
49 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
50 |
in_group = SubjectRelation('CWGroup', cardinality='+*', |
0 | 51 |
constraints=[RQLConstraint('NOT O name "owners"')], |
52 |
description=_('groups grant permissions to the user')) |
|
53 |
||
54 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
55 |
class EmailAddress(EntityType): |
0 | 56 |
"""an electronic mail address associated to a short alias""" |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
57 |
__permissions__ = { |
0 | 58 |
'read': ('managers', 'users', 'guests',), # XXX if P use_email X, U has_read_permission P |
59 |
'add': ('managers', 'users',), |
|
60 |
'delete': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')), |
|
61 |
'update': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')), |
|
62 |
} |
|
1451 | 63 |
|
0 | 64 |
alias = String(fulltextindexed=True, maxsize=56) |
1451 | 65 |
address = String(required=True, fulltextindexed=True, |
0 | 66 |
indexed=True, unique=True, maxsize=128) |
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
67 |
prefered_form = SubjectRelation('EmailAddress', cardinality='?*', |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
68 |
description=_('when multiple addresses are equivalent \ |
0 | 69 |
(such as python-projects@logilab.org and python-projects@lists.logilab.org), set this \ |
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
70 |
to indicate which is the preferred form.')) |
0 | 71 |
|
72 |
class use_email(RelationType): |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1477
diff
changeset
|
73 |
""" """ |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
74 |
__permissions__ = { |
0 | 75 |
'read': ('managers', 'users', 'guests',), |
76 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
|
77 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
|
78 |
} |
|
79 |
fulltext_container = 'subject' |
|
80 |
||
81 |
class primary_email(RelationType): |
|
82 |
"""the prefered email""" |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
83 |
__permissions__ = use_email.__permissions__ |
1451 | 84 |
|
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
85 |
class prefered_form(RelationType): |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
86 |
__permissions__ = { |
0 | 87 |
'read': ('managers', 'users', 'guests',), |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
88 |
# XXX should have update __permissions__ on both subject and object, |
0 | 89 |
# though by doing this we will probably have no way to add |
90 |
# this relation in the web ui. The easiest way to acheive this |
|
91 |
# is probably to be able to have "U has_update_permission O" as |
|
92 |
# RQLConstraint of the relation definition, though this is not yet |
|
93 |
# possible |
|
94 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
|
95 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
|
96 |
} |
|
97 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
98 |
class in_group(RelationType): |
0 | 99 |
"""core relation indicating a user's groups""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
100 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
1451 | 101 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
102 |
class owned_by(RelationType): |
0 | 103 |
"""core relation indicating owners of an entity. This relation |
104 |
implicitly put the owner into the owners group for the entity |
|
105 |
""" |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
106 |
__permissions__ = { |
0 | 107 |
'read': ('managers', 'users', 'guests'), |
1451 | 108 |
'add': ('managers', RRQLExpression('S owned_by U'),), |
0 | 109 |
'delete': ('managers', RRQLExpression('S owned_by U'),), |
110 |
} |
|
111 |
# 0..n cardinality for entities created by internal session (no attached user) |
|
112 |
# and to support later deletion of a user which has created some entities |
|
113 |
cardinality = '**' |
|
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2297
diff
changeset
|
114 |
subject = '*' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
115 |
object = 'CWUser' |
1451 | 116 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
117 |
class created_by(RelationType): |
0 | 118 |
"""core relation indicating the original creator of an entity""" |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
119 |
__permissions__ = { |
0 | 120 |
'read': ('managers', 'users', 'guests'), |
121 |
'add': ('managers',), |
|
122 |
'delete': ('managers',), |
|
123 |
} |
|
124 |
# 0..1 cardinality for entities created by internal session (no attached user) |
|
125 |
# and to support later deletion of a user which has created some entities |
|
1451 | 126 |
cardinality = '?*' |
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2297
diff
changeset
|
127 |
subject = '*' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
128 |
object = 'CWUser' |
0 | 129 |
|
1451 | 130 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
131 |
class creation_date(RelationType): |
0 | 132 |
"""creation time of an entity""" |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
133 |
__permissions__ = PUB_SYSTEM_ATTR_PERMS |
0 | 134 |
cardinality = '11' |
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2297
diff
changeset
|
135 |
subject = '*' |
0 | 136 |
object = 'Datetime' |
137 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
138 |
class modification_date(RelationType): |
0 | 139 |
"""latest modification time of an entity""" |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
140 |
__permissions__ = PUB_SYSTEM_ATTR_PERMS |
0 | 141 |
cardinality = '11' |
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2297
diff
changeset
|
142 |
subject = '*' |
0 | 143 |
object = 'Datetime' |
144 |
||
2456
aa25d6b244c8
new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2441
diff
changeset
|
145 |
class cwuri(RelationType): |
aa25d6b244c8
new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2441
diff
changeset
|
146 |
"""internal entity uri""" |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
147 |
__permissions__ = PUB_SYSTEM_ATTR_PERMS |
2456
aa25d6b244c8
new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2441
diff
changeset
|
148 |
cardinality = '11' |
2464
926696e38502
usage of '**' is deprecated in RelationType declaration, use '*' instead
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2456
diff
changeset
|
149 |
subject = '*' |
2456
aa25d6b244c8
new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2441
diff
changeset
|
150 |
object = 'String' |
aa25d6b244c8
new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2441
diff
changeset
|
151 |
|
0 | 152 |
|
3392
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3277
diff
changeset
|
153 |
# XXX find a better relation name |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
154 |
class for_user(RelationType): |
0 | 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 |
""" |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
158 |
__permissions__ = { |
0 | 159 |
'read': ('managers', 'users', 'guests'), |
160 |
'add': ('managers',), |
|
161 |
'delete': ('managers',), |
|
162 |
} |
|
163 |
inlined = True |
|
3392
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3277
diff
changeset
|
164 |
subject = 'CWProperty' |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3277
diff
changeset
|
165 |
object = 'CWUser' |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3277
diff
changeset
|
166 |
composite = 'object' |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3277
diff
changeset
|
167 |
cardinality = '?*' |
0 | 168 |
|
169 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
170 |
class CWPermission(EntityType): |
0 | 171 |
"""entity type that may be used to construct some advanced security configuration |
172 |
""" |
|
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
173 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
174 |
|
0 | 175 |
name = String(required=True, indexed=True, internationalizable=True, maxsize=100, |
176 |
description=_('name or identifier of the permission')) |
|
177 |
label = String(required=True, internationalizable=True, maxsize=100, |
|
5577
4e3ca117c275
[schema] fix same_as cardinality and bump Bookmark.path max length to approximative max url size
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
178 |
description=_('distinct label to distinguate between other ' |
4e3ca117c275
[schema] fix same_as cardinality and bump Bookmark.path max length to approximative max url size
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
179 |
'permission entity of the same name')) |
1451 | 180 |
require_group = SubjectRelation('CWGroup', |
0 | 181 |
description=_('groups to which the permission is granted')) |
182 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1303
diff
changeset
|
183 |
# explicitly add X require_permission CWPermission for each entity that should have |
0 | 184 |
# configurable security |
185 |
class require_permission(RelationType): |
|
186 |
"""link a permission to the entity. This permission should be used in the |
|
187 |
security definition of the entity's type to be useful. |
|
188 |
""" |
|
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
189 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
1451 | 190 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
191 |
class require_group(RelationType): |
0 | 192 |
"""used to grant a permission to a group""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
193 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
0 | 194 |
|
1451 | 195 |
|
2434
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
196 |
class ExternalUri(EntityType): |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
197 |
"""a URI representing an object in external data store""" |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
198 |
uri = String(required=True, unique=True, maxsize=256, |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
199 |
description=_('the URI of the object')) |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
200 |
|
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
201 |
class same_as(RelationType): |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
202 |
"""generic relation to specify that an external entity represent the same |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
203 |
object as a local one: |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
204 |
http://www.w3.org/TR/owl-ref/#sameAs-def |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
205 |
""" |
4535
71c86a315a9a
update translatable docstring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
206 |
#NOTE: You'll have to explicitly declare which entity types can have a |
71c86a315a9a
update translatable docstring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
207 |
#same_as relation |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
208 |
__permissions__ = { |
2434
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
209 |
'read': ('managers', 'users', 'guests',), |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
210 |
'add': ('managers', 'users'), |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
211 |
'delete': ('managers', 'owners'), |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
212 |
} |
5577
4e3ca117c275
[schema] fix same_as cardinality and bump Bookmark.path max length to approximative max url size
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
213 |
cardinality = '**' |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
214 |
symmetric = True |
2434
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
215 |
# NOTE: the 'object = ExternalUri' declaration will still be mandatory |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
216 |
# in the cube's schema. |
ed85d69576b4
add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2297
diff
changeset
|
217 |
object = 'ExternalUri' |
1477 | 218 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
219 |
class CWCache(EntityType): |
59
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
220 |
"""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
|
221 |
a validity date. |
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
222 |
|
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
223 |
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
|
224 |
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
|
225 |
|
2656
a93ae0f6c0ad
R [base classes] only AppObject remaning, no more AppRsetObject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2464
diff
changeset
|
226 |
Also, checkout the AppObject.get_cache() method. |
59
9660bd221553
ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6
diff
changeset
|
227 |
""" |
4759 | 228 |
# XXX only handle by hooks, shouldn't be readable/editable at all through |
229 |
# the ui and so no permissions should be granted, no? |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
230 |
__permissions__ = { |
6
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
231 |
'read': ('managers', 'users', 'guests'), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
232 |
'add': ('managers',), |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
233 |
'update': ('managers', 'users',), # XXX |
6
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
234 |
'delete': ('managers',), |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
235 |
} |
29ab115b9fcb
change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
0
diff
changeset
|
236 |
|
1445
d3c9b075ceb7
set a size constraint on ECache's title
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1281
diff
changeset
|
237 |
name = String(required=True, unique=True, indexed=True, maxsize=128, |
0 | 238 |
description=_('name of the cache')) |
239 |
timestamp = Datetime(default='NOW') |
|
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
240 |
|
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
241 |
|
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
242 |
# "abtract" relation types, not used in cubicweb itself |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
243 |
|
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
244 |
class identical_to(RelationType): |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
245 |
"""identical to""" |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
246 |
symmetric = True |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
247 |
__permissions__ = { |
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
248 |
'read': ('managers', 'users', 'guests',), |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
249 |
# XXX should have update __permissions__ on both subject and object, |
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
250 |
# though by doing this we will probably have no way to add |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
251 |
# this relation in the web ui. The easiest way to acheive this |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
252 |
# is probably to be able to have "U has_update_permission O" as |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
253 |
# RQLConstraint of the relation definition, though this is not yet |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
254 |
# possible |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
255 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
256 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
257 |
} |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
258 |
|
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
259 |
class see_also(RelationType): |
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2656
diff
changeset
|
260 |
"""generic relation to link one entity to another""" |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
261 |
symmetric = True |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3277
diff
changeset
|
262 |
__permissions__ = { |
3277
4fdb165ae3de
fix see_also permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3204
diff
changeset
|
263 |
'read': ('managers', 'users', 'guests',), |
4fdb165ae3de
fix see_also permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3204
diff
changeset
|
264 |
'add': ('managers', RRQLExpression('U has_update_permission S'),), |
4fdb165ae3de
fix see_also permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3204
diff
changeset
|
265 |
'delete': ('managers', RRQLExpression('U has_update_permission S'),), |
4fdb165ae3de
fix see_also permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3204
diff
changeset
|
266 |
} |