author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 28 Apr 2010 12:15:52 +0200 | |
branch | oldstable |
changeset 5424 | 8ecbcbff9777 |
parent 5421 | 8167de96c523 |
child 5426 | 0d4853a6e5ee |
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
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:
5030
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""schema definition related entities |
19 |
||
20 |
""" |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
23 |
from logilab.common.decorators import cached |
|
24 |
||
5030
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4839
diff
changeset
|
25 |
from yams.schema import role_name |
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4839
diff
changeset
|
26 |
|
0 | 27 |
from cubicweb import ValidationError |
28 |
from cubicweb.schema import ERQLExpression, RRQLExpression |
|
29 |
||
30 |
from cubicweb.entities import AnyEntity, fetch_config |
|
31 |
||
32 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
33 |
class CWEType(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
34 |
__regid__ = 'CWEType' |
0 | 35 |
fetch_attrs, fetch_order = fetch_config(['name']) |
1154 | 36 |
|
0 | 37 |
def dc_title(self): |
3432
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
38 |
return u'%s (%s)' % (self.name, self._cw._(self.name)) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
39 |
|
0 | 40 |
def dc_long_title(self): |
41 |
stereotypes = [] |
|
3432
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
42 |
_ = self._cw._ |
0 | 43 |
if self.final: |
44 |
stereotypes.append(_('final')) |
|
45 |
if stereotypes: |
|
46 |
return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes)) |
|
47 |
return self.dc_title() |
|
48 |
||
49 |
def db_key_name(self): |
|
50 |
"""XXX goa specific""" |
|
51 |
return self.get('name') |
|
52 |
||
53 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
54 |
class CWRType(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
55 |
__regid__ = 'CWRType' |
0 | 56 |
fetch_attrs, fetch_order = fetch_config(['name']) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
57 |
|
0 | 58 |
def dc_title(self): |
3432
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
59 |
return u'%s (%s)' % (self.name, self._cw._(self.name)) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
60 |
|
0 | 61 |
def dc_long_title(self): |
62 |
stereotypes = [] |
|
3432
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
63 |
_ = self._cw._ |
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
|
64 |
if self.symmetric: |
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
|
65 |
stereotypes.append(_('symmetric')) |
0 | 66 |
if self.inlined: |
67 |
stereotypes.append(_('inlined')) |
|
68 |
if self.final: |
|
69 |
stereotypes.append(_('final')) |
|
70 |
if stereotypes: |
|
71 |
return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes)) |
|
72 |
return self.dc_title() |
|
73 |
||
4839
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
74 |
def check_inlined_allowed(self): |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
75 |
"""check inlining is possible, raise ValidationError if not possible |
0 | 76 |
""" |
4839
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
77 |
# don't use the persistent schema, we may miss cardinality changes |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
78 |
# in the same transaction |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
79 |
for rdef in self.reverse_relation_type: |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
80 |
card = rdef.cardinality[0] |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
81 |
if not card in '?1': |
5030
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4839
diff
changeset
|
82 |
qname = role_name('inlined', 'subject') |
4839
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
83 |
rtype = self.name |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
84 |
stype = rdef.stype |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
85 |
otype = rdef.otype |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
86 |
msg = self._cw._("can't set inlined=%(inlined)s, " |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
87 |
"%(stype)s %(rtype)s %(otype)s " |
f482dbdf2f8c
[schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
88 |
"has cardinality=%(card)s") |
5030
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4839
diff
changeset
|
89 |
raise ValidationError(self.eid, {qname: msg % locals()}) |
0 | 90 |
|
91 |
def db_key_name(self): |
|
92 |
"""XXX goa specific""" |
|
93 |
return self.get('name') |
|
94 |
||
95 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
96 |
class CWRelation(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
97 |
__regid__ = 'CWRelation' |
0 | 98 |
fetch_attrs = fetch_config(['cardinality'])[0] |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
99 |
|
0 | 100 |
def dc_title(self): |
101 |
return u'%s %s %s' % ( |
|
102 |
self.from_entity[0].name, |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
103 |
self.relation_type[0].name, |
0 | 104 |
self.to_entity[0].name) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
105 |
|
0 | 106 |
def dc_long_title(self): |
107 |
card = self.cardinality |
|
108 |
scard, ocard = u'', u'' |
|
109 |
if card[0] != '1': |
|
110 |
scard = '[%s]' % card[0] |
|
111 |
if card[1] != '1': |
|
112 |
ocard = '[%s]' % card[1] |
|
113 |
return u'%s %s%s%s %s' % ( |
|
114 |
self.from_entity[0].name, |
|
115 |
scard, self.relation_type[0].name, ocard, |
|
116 |
self.to_entity[0].name) |
|
117 |
||
118 |
def after_deletion_path(self): |
|
119 |
"""return (path, parameters) which should be used as redirect |
|
120 |
information when this entity is being deleted |
|
121 |
""" |
|
122 |
if self.relation_type: |
|
123 |
return self.relation_type[0].rest_path(), {} |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
124 |
return super(CWRelation, self).after_deletion_path() |
0 | 125 |
|
2594
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
126 |
@property |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
127 |
def rtype(self): |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
128 |
return self.relation_type[0] |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
129 |
|
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
130 |
@property |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
131 |
def stype(self): |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
132 |
return self.from_entity[0] |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
133 |
|
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
134 |
@property |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
135 |
def otype(self): |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
136 |
return self.to_entity[0] |
92aad5e18405
[R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2299
diff
changeset
|
137 |
|
0 | 138 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
139 |
class CWAttribute(CWRelation): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
140 |
__regid__ = 'CWAttribute' |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
141 |
|
0 | 142 |
def dc_long_title(self): |
143 |
card = self.cardinality |
|
144 |
scard = u'' |
|
145 |
if card[0] == '1': |
|
146 |
scard = '+' |
|
147 |
return u'%s %s%s %s' % ( |
|
148 |
self.from_entity[0].name, |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
149 |
scard, self.relation_type[0].name, |
0 | 150 |
self.to_entity[0].name) |
151 |
||
152 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
153 |
class CWConstraint(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
154 |
__regid__ = 'CWConstraint' |
0 | 155 |
fetch_attrs, fetch_order = fetch_config(['value']) |
156 |
||
157 |
def dc_title(self): |
|
158 |
return '%s(%s)' % (self.cstrtype[0].name, self.value or u'') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
159 |
|
0 | 160 |
def after_deletion_path(self): |
161 |
"""return (path, parameters) which should be used as redirect |
|
162 |
information when this entity is being deleted |
|
163 |
""" |
|
164 |
if self.reverse_constrained_by: |
|
165 |
return self.reverse_constrained_by[0].rest_path(), {} |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
166 |
return super(CWConstraint, self).after_deletion_path() |
0 | 167 |
|
168 |
@property |
|
169 |
def type(self): |
|
170 |
return self.cstrtype[0].name |
|
171 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
172 |
|
0 | 173 |
class RQLExpression(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
174 |
__regid__ = 'RQLExpression' |
0 | 175 |
fetch_attrs, fetch_order = fetch_config(['exprtype', 'mainvars', 'expression']) |
176 |
||
177 |
def dc_title(self): |
|
178 |
return '%s(%s)' % (self.exprtype, self.expression or u'') |
|
179 |
||
180 |
@property |
|
181 |
def expression_of(self): |
|
182 |
for rel in ('read_permission', 'add_permission', 'delete_permission', |
|
183 |
'update_permission', 'condition'): |
|
184 |
values = getattr(self, 'reverse_%s' % rel) |
|
185 |
if values: |
|
186 |
return values[0] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
187 |
|
0 | 188 |
@cached |
189 |
def _rqlexpr(self): |
|
190 |
if self.exprtype == 'ERQLExpression': |
|
191 |
return ERQLExpression(self.expression, self.mainvars, self.eid) |
|
192 |
#if self.exprtype == 'RRQLExpression': |
|
193 |
return RRQLExpression(self.expression, self.mainvars, self.eid) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
194 |
|
0 | 195 |
def check_expression(self, *args, **kwargs): |
196 |
return self._rqlexpr().check(*args, **kwargs) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
197 |
|
0 | 198 |
def after_deletion_path(self): |
199 |
"""return (path, parameters) which should be used as redirect |
|
200 |
information when this entity is being deleted |
|
201 |
""" |
|
202 |
if self.expression_of: |
|
203 |
return self.expression_of.rest_path(), {} |
|
204 |
return super(RQLExpression, self).after_deletion_path() |
|
205 |
||
206 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
207 |
class CWPermission(AnyEntity): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3353
diff
changeset
|
208 |
__regid__ = 'CWPermission' |
0 | 209 |
fetch_attrs, fetch_order = fetch_config(['name', 'label']) |
210 |
||
211 |
def dc_title(self): |
|
212 |
if self.label: |
|
3432
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
213 |
return '%s (%s)' % (self._cw._(self.name), self.label) |
12fe502e5044
use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3377
diff
changeset
|
214 |
return self._cw._(self.name) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
215 |
|
0 | 216 |
def after_deletion_path(self): |
217 |
"""return (path, parameters) which should be used as redirect |
|
218 |
information when this entity is being deleted |
|
219 |
""" |
|
220 |
permissionof = getattr(self, 'reverse_require_permission', ()) |
|
221 |
if len(permissionof) == 1: |
|
222 |
return permissionof[0].rest_path(), {} |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1154
diff
changeset
|
223 |
return super(CWPermission, self).after_deletion_path() |