author | Rémi Cardona <remi.cardona@logilab.fr> |
Wed, 28 Jan 2015 11:51:16 +0100 | |
changeset 10164 | 2094262d6553 |
parent 9965 | a8769b752299 |
child 10316 | 4ce8b8437838 |
permissions | -rw-r--r-- |
8945
ba9e3fbfa5a5
[schemaserial] serialize additional yams parameter for customs type
Vincent Michel <vincent.michel@logilab.fr>
parents:
6815
diff
changeset
|
1 |
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
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:
5179
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2459
diff
changeset
|
18 |
"""core CubicWeb schema necessary for bootstrapping the actual instance's schema |
5782
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
19 |
""" |
0 | 20 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
21 |
__docformat__ = "restructuredtext en" |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
22 |
_ = unicode |
0 | 23 |
|
8945
ba9e3fbfa5a5
[schemaserial] serialize additional yams parameter for customs type
Vincent Michel <vincent.michel@logilab.fr>
parents:
6815
diff
changeset
|
24 |
from yams.buildobjs import (EntityType, RelationType, RelationDefinition, Bytes, |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
25 |
SubjectRelation, RichString, String, Boolean, Int) |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
26 |
from cubicweb.schema import ( |
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
27 |
RQLConstraint, |
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
28 |
PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, PUB_SYSTEM_ATTR_PERMS |
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
29 |
) |
0 | 30 |
|
31 |
# not restricted since as "is" is handled as other relations, guests need |
|
32 |
# access to this |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
33 |
class CWEType(EntityType): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2459
diff
changeset
|
34 |
"""define an entity type, used to build the instance schema""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
35 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
0 | 36 |
name = String(required=True, indexed=True, internationalizable=True, |
37 |
unique=True, maxsize=64) |
|
1451 | 38 |
description = RichString(internationalizable=True, |
627
36ade1128af7
use RichString wherever possible in the stdlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
39 |
description=_('semantic description of this entity type')) |
0 | 40 |
# necessary to filter using RQL |
41 |
final = Boolean(description=_('automatic')) |
|
42 |
||
43 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
44 |
class CWRType(EntityType): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2459
diff
changeset
|
45 |
"""define a relation type, used to build the instance schema""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
46 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
0 | 47 |
name = String(required=True, indexed=True, internationalizable=True, |
48 |
unique=True, maxsize=64) |
|
2129
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
49 |
description = RichString(internationalizable=True, |
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
50 |
description=_('semantic description of this relation type')) |
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:
4319
diff
changeset
|
51 |
symmetric = Boolean(description=_('is this relation equivalent in both direction ?')) |
0 | 52 |
inlined = Boolean(description=_('is this relation physically inlined? you should know what you\'re doing if you are changing this!')) |
53 |
fulltext_container = String(description=_('if full text content of subject/object entity ' |
|
54 |
'should be added to other side entity (the container).'), |
|
55 |
vocabulary=('', _('subject'), _('object')), |
|
56 |
maxsize=8, default=None) |
|
57 |
final = Boolean(description=_('automatic')) |
|
58 |
||
59 |
||
9956
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
60 |
class CWComputedRType(EntityType): |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
61 |
"""define a virtual relation type, used to build the instance schema""" |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
62 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
63 |
name = String(required=True, indexed=True, internationalizable=True, |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
64 |
unique=True, maxsize=64) |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
65 |
description = RichString(internationalizable=True, |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
66 |
description=_('semantic description of this relation type')) |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
67 |
rule = String(required=True) |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
68 |
|
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9395
diff
changeset
|
69 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
70 |
class CWAttribute(EntityType): |
0 | 71 |
"""define a final relation: link a final relation type from a non final |
1451 | 72 |
entity to a final entity type. |
0 | 73 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2459
diff
changeset
|
74 |
used to build the instance schema |
0 | 75 |
""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
76 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
77 |
relation_type = SubjectRelation('CWRType', cardinality='1*', |
0 | 78 |
constraints=[RQLConstraint('O final TRUE')], |
79 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
80 |
from_entity = SubjectRelation('CWEType', cardinality='1*', |
0 | 81 |
constraints=[RQLConstraint('O final FALSE')], |
82 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
83 |
to_entity = SubjectRelation('CWEType', cardinality='1*', |
0 | 84 |
constraints=[RQLConstraint('O final TRUE')], |
85 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
86 |
constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject') |
1451 | 87 |
|
0 | 88 |
cardinality = String(maxsize=2, internationalizable=True, |
1979
daf297034197
remove meaningless cards for attributes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
89 |
vocabulary=[_('?1'), _('11')], |
0 | 90 |
description=_('subject/object cardinality')) |
91 |
ordernum = Int(description=('control subject entity\'s relations order'), default=0) |
|
1451 | 92 |
|
9965
a8769b752299
[CWEP002] Account for attribute formula in schema bootstrap
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9956
diff
changeset
|
93 |
formula = String(maxsize=2048) |
0 | 94 |
indexed = Boolean(description=_('create an index for quick search on this attribute')) |
95 |
fulltextindexed = Boolean(description=_('index this attribute\'s value in the plain text index')) |
|
96 |
internationalizable = Boolean(description=_('is this attribute\'s value translatable')) |
|
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8945
diff
changeset
|
97 |
defaultval = Bytes(description=_('default value as gziped pickled python object')) |
8945
ba9e3fbfa5a5
[schemaserial] serialize additional yams parameter for customs type
Vincent Michel <vincent.michel@logilab.fr>
parents:
6815
diff
changeset
|
98 |
extra_props = Bytes(description=_('additional type specific properties')) |
1451 | 99 |
|
2129
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
100 |
description = RichString(internationalizable=True, |
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
101 |
description=_('semantic description of this attribute')) |
1451 | 102 |
|
0 | 103 |
|
1451 | 104 |
CARDINALITY_VOCAB = [_('?*'), _('1*'), _('+*'), _('**'), |
105 |
_('?+'), _('1+'), _('++'), _('*+'), |
|
0 | 106 |
_('?1'), _('11'), _('+1'), _('*1'), |
107 |
_('??'), _('1?'), _('+?'), _('*?')] |
|
108 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
109 |
class CWRelation(EntityType): |
0 | 110 |
"""define a non final relation: link a non final relation type from a non |
1451 | 111 |
final entity to a non final entity type. |
0 | 112 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2459
diff
changeset
|
113 |
used to build the instance schema |
0 | 114 |
""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
115 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
116 |
relation_type = SubjectRelation('CWRType', cardinality='1*', |
0 | 117 |
constraints=[RQLConstraint('O final FALSE')], |
118 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
119 |
from_entity = SubjectRelation('CWEType', cardinality='1*', |
0 | 120 |
constraints=[RQLConstraint('O final FALSE')], |
121 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
122 |
to_entity = SubjectRelation('CWEType', cardinality='1*', |
0 | 123 |
constraints=[RQLConstraint('O final FALSE')], |
124 |
composite='object') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
125 |
constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject') |
1451 | 126 |
|
0 | 127 |
cardinality = String(maxsize=2, internationalizable=True, |
128 |
vocabulary=CARDINALITY_VOCAB, |
|
129 |
description=_('subject/object cardinality')) |
|
130 |
ordernum = Int(description=_('control subject entity\'s relations order'), |
|
131 |
default=0) |
|
132 |
composite = String(description=_('is the subject/object entity of the relation ' |
|
133 |
'composed of the other ? This implies that when ' |
|
134 |
'the composite is deleted, composants are also ' |
|
135 |
'deleted.'), |
|
136 |
vocabulary=('', _('subject'), _('object')), |
|
137 |
maxsize=8, default=None) |
|
1451 | 138 |
|
2129
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
139 |
description = RichString(internationalizable=True, |
fbfab570a276
use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2127
diff
changeset
|
140 |
description=_('semantic description of this relation')) |
1451 | 141 |
|
0 | 142 |
|
143 |
# not restricted since it has to be read when checking allowed transitions |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
144 |
class RQLExpression(EntityType): |
4535
71c86a315a9a
update translatable docstring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
145 |
"""define a rql expression used to define permissions""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
146 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
0 | 147 |
exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression']) |
148 |
mainvars = String(maxsize=8, |
|
149 |
description=_('name of the main variables which should be ' |
|
150 |
'used in the selection if necessary (comma ' |
|
151 |
'separated)')) |
|
1451 | 152 |
expression = String(required=True, |
0 | 153 |
description=_('restriction part of a rql query. ' |
154 |
'For entity rql expression, X and U are ' |
|
155 |
'predefined respectivly to the current object and to ' |
|
156 |
'the request user. For relation rql expression, ' |
|
157 |
'S, O and U are predefined respectivly to the current ' |
|
158 |
'relation\'subject, object and to ' |
|
159 |
'the request user. ')) |
|
160 |
||
161 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
162 |
class CWConstraint(EntityType): |
0 | 163 |
"""define a schema constraint""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
164 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
165 |
cstrtype = SubjectRelation('CWConstraintType', cardinality='1*') |
0 | 166 |
value = String(description=_('depends on the constraint type')) |
167 |
||
168 |
||
6208
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
169 |
class CWUniqueTogetherConstraint(EntityType): |
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
170 |
"""defines a sql-level multicolumn unique index""" |
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
171 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
9375
8e88576787c3
[schema] fix unique together index handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
172 |
name = String(required=True, unique=True, maxsize=64) |
6208
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
173 |
constraint_of = SubjectRelation('CWEType', cardinality='1*', composite='object', |
6209 | 174 |
inlined=True) |
6815
a84190d4e78c
[schema] fix pb with ambiguous relation used within UniqueTogetherConstraint by having CWUniqueTogetherConstraint.relation targeting CWRType instead of CWAttribute/CWRelation. This fixes 3.10.7 migration.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
175 |
relations = SubjectRelation('CWRType', cardinality='+*', |
a84190d4e78c
[schema] fix pb with ambiguous relation used within UniqueTogetherConstraint by having CWUniqueTogetherConstraint.relation targeting CWRType instead of CWAttribute/CWRelation. This fixes 3.10.7 migration.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
176 |
constraints=[RQLConstraint( |
a84190d4e78c
[schema] fix pb with ambiguous relation used within UniqueTogetherConstraint by having CWUniqueTogetherConstraint.relation targeting CWRType instead of CWAttribute/CWRelation. This fixes 3.10.7 migration.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
177 |
'S constraint_of ET, RDEF relation_type O, RDEF from_entity ET, ' |
a84190d4e78c
[schema] fix pb with ambiguous relation used within UniqueTogetherConstraint by having CWUniqueTogetherConstraint.relation targeting CWRType instead of CWAttribute/CWRelation. This fixes 3.10.7 migration.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
178 |
'O final TRUE OR (O final FALSE AND O inlined TRUE)')]) |
6208
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
179 |
|
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5782
diff
changeset
|
180 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
181 |
class CWConstraintType(EntityType): |
0 | 182 |
"""define a schema constraint type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
183 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
0 | 184 |
name = String(required=True, indexed=True, internationalizable=True, |
185 |
unique=True, maxsize=64) |
|
186 |
||
187 |
||
188 |
# not restricted since it has to be read when checking allowed transitions |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
189 |
class CWGroup(EntityType): |
0 | 190 |
"""define a CubicWeb users group""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
191 |
__permissions__ = PUB_SYSTEM_ENTITY_PERMS |
0 | 192 |
name = String(required=True, indexed=True, internationalizable=True, |
193 |
unique=True, maxsize=64) |
|
194 |
||
1451 | 195 |
|
3392
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
196 |
class CWProperty(EntityType): |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
197 |
"""used for cubicweb configuration. Once a property has been created you |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
198 |
can't change the key. |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
199 |
""" |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
200 |
__permissions__ = { |
3392
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
201 |
'read': ('managers', 'users', 'guests'), |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
202 |
'add': ('managers', 'users',), |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
203 |
'update': ('managers', 'owners',), |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
204 |
'delete': ('managers', 'owners',), |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
205 |
} |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
206 |
# key is a reserved word for mysql |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
207 |
pkey = String(required=True, internationalizable=True, maxsize=256, |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
208 |
description=_('defines what\'s the property is applied for. ' |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
209 |
'You must select this first to be able to set ' |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
210 |
'value')) |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
211 |
value = String(internationalizable=True, maxsize=256) |
36bcf206e157
[schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
212 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
213 |
class relation_type(RelationType): |
0 | 214 |
"""link a relation definition to its relation type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
215 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
0 | 216 |
inlined = True |
1451 | 217 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
218 |
class from_entity(RelationType): |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
219 |
"""link a relation definition to its subject entity type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
220 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
0 | 221 |
inlined = True |
222 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
223 |
class to_entity(RelationType): |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
224 |
"""link a relation definition to its object entity type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
225 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
226 |
inlined = True |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
227 |
|
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
228 |
class constrained_by(RelationType): |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
229 |
"""constraints applying on this relation""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
230 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
231 |
|
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
232 |
class cstrtype(RelationType): |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
233 |
"""constraint factory""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
234 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
235 |
inlined = True |
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
236 |
|
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
237 |
|
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
238 |
class read_permission_cwgroup(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
239 |
"""groups allowed to read entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
240 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
241 |
name = 'read_permission' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
242 |
subject = ('CWEType', 'CWAttribute', 'CWRelation') |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
243 |
object = 'CWGroup' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
244 |
cardinality = '**' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
245 |
|
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
246 |
class add_permission_cwgroup(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
247 |
"""groups allowed to add entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
248 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
249 |
name = 'add_permission' |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9375
diff
changeset
|
250 |
subject = ('CWEType', 'CWRelation', 'CWAttribute') |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
251 |
object = 'CWGroup' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
252 |
cardinality = '**' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
253 |
|
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
254 |
class delete_permission_cwgroup(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
255 |
"""groups allowed to delete entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
256 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
257 |
name = 'delete_permission' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
258 |
subject = ('CWEType', 'CWRelation') |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
259 |
object = 'CWGroup' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
260 |
cardinality = '**' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
261 |
|
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
262 |
class update_permission_cwgroup(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
263 |
"""groups allowed to update entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
264 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
265 |
name = 'update_permission' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
266 |
subject = ('CWEType', 'CWAttribute') |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
267 |
object = 'CWGroup' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
268 |
cardinality = '**' |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
269 |
|
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
270 |
class read_permission_rqlexpr(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
271 |
"""rql expression allowing to read entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
272 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
273 |
name = 'read_permission' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
274 |
subject = ('CWEType', 'CWAttribute', 'CWRelation') |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
275 |
object = 'RQLExpression' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
276 |
cardinality = '*?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
277 |
composite = 'subject' |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
278 |
|
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
279 |
class add_permission_rqlexpr(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
280 |
"""rql expression allowing to add entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
281 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
282 |
name = 'add_permission' |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9375
diff
changeset
|
283 |
subject = ('CWEType', 'CWRelation', 'CWAttribute') |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
284 |
object = 'RQLExpression' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
285 |
cardinality = '*?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
286 |
composite = 'subject' |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
287 |
|
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
288 |
class delete_permission_rqlexpr(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
289 |
"""rql expression allowing to delete entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
290 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
291 |
name = 'delete_permission' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
292 |
subject = ('CWEType', 'CWRelation') |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
293 |
object = 'RQLExpression' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
294 |
cardinality = '*?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
295 |
composite = 'subject' |
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
296 |
|
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
297 |
class update_permission_rqlexpr(RelationDefinition): |
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
298 |
"""rql expression allowing to update entities/relations of this type""" |
4754
6bf17f810975
[schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4588
diff
changeset
|
299 |
__permissions__ = PUB_SYSTEM_REL_PERMS |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
300 |
name = 'update_permission' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
301 |
subject = ('CWEType', 'CWAttribute') |
4588
36b700c00d38
fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
302 |
object = 'RQLExpression' |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
303 |
cardinality = '*?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4535
diff
changeset
|
304 |
composite = 'subject' |
0 | 305 |
|
306 |
||
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
307 |
class is_(RelationType): |
0 | 308 |
"""core relation indicating the type of an entity |
309 |
""" |
|
310 |
name = 'is' |
|
311 |
# don't explicitly set composite here, this is handled anyway |
|
312 |
#composite = 'object' |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
313 |
__permissions__ = { |
0 | 314 |
'read': ('managers', 'users', 'guests'), |
315 |
'add': (), |
|
316 |
'delete': (), |
|
317 |
} |
|
318 |
cardinality = '1*' |
|
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2140
diff
changeset
|
319 |
subject = '*' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
320 |
object = 'CWEType' |
0 | 321 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
322 |
class is_instance_of(RelationType): |
0 | 323 |
"""core relation indicating the types (including specialized types) |
324 |
of an entity |
|
325 |
""" |
|
326 |
# don't explicitly set composite here, this is handled anyway |
|
327 |
#composite = 'object' |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
328 |
__permissions__ = { |
0 | 329 |
'read': ('managers', 'users', 'guests'), |
330 |
'add': (), |
|
331 |
'delete': (), |
|
332 |
} |
|
333 |
cardinality = '+*' |
|
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2140
diff
changeset
|
334 |
subject = '*' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
335 |
object = 'CWEType' |
0 | 336 |
|
2140
1cba3393ba01
update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2129
diff
changeset
|
337 |
class specializes(RelationType): |
0 | 338 |
name = 'specializes' |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
339 |
__permissions__ = { |
0 | 340 |
'read': ('managers', 'users', 'guests'), |
341 |
'add': ('managers',), |
|
342 |
'delete': ('managers',), |
|
343 |
} |
|
344 |
cardinality = '?*' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
345 |
subject = 'CWEType' |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
628
diff
changeset
|
346 |
object = 'CWEType' |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
347 |
|
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
348 |
def post_build_callback(schema): |
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
349 |
"""set attributes permissions for schema/workflow entities""" |
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
350 |
from cubicweb.schema import SCHEMA_TYPES, WORKFLOW_TYPES, META_RTYPES |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4755
diff
changeset
|
351 |
wftypes = WORKFLOW_TYPES - set(('TrInfo',)) |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
352 |
for eschema in schema.entities(): |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4755
diff
changeset
|
353 |
if eschema in SCHEMA_TYPES or eschema in wftypes: |
4755
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
354 |
for rschema in eschema.subject_relations(): |
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
355 |
if rschema.final and not rschema in META_RTYPES: |
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
356 |
rdef = eschema.rdef(rschema) |
13a5d3a7410e
[schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4754
diff
changeset
|
357 |
rdef.permissions = PUB_SYSTEM_ATTR_PERMS |