author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 16 Sep 2009 16:39:03 +0200 | |
branch | 3.5 |
changeset 3253 | 905e269ff853 |
parent 3184 | 613064b49331 |
child 3185 | bd0126d17e83 |
child 3264 | 5d1f3f6c042d |
permissions | -rw-r--r-- |
1739 | 1 |
"""This module regroups a set of structures that may be used to configure |
2 |
various places of the generated web interface. |
|
3 |
||
4 |
Primary view configuration |
|
5 |
`````````````````````````` |
|
6 |
:primaryview_section: |
|
7 |
where to display a relation in primary view. Value may be one of: |
|
8 |
* 'attributes', display in the attributes section |
|
9 |
* 'relations', display in the relations section (below attributes) |
|
10 |
* 'sideboxes', display in the side boxes (beside attributes) |
|
11 |
* 'hidden', don't display |
|
12 |
||
13 |
:primaryview_display_ctrl: |
|
14 |
||
15 |
how to display a relation in primary view. Values are dict with some of the |
|
16 |
following keys: |
|
17 |
||
18 |
:vid: |
|
19 |
identifier of a view to use to display the result set. Defaults depends on |
|
20 |
the section: |
|
21 |
* 'attributes' section: 'reledit' view |
|
22 |
* 'relations' section: 'autolimited' view |
|
23 |
* 'sideboxes' section: 'sidebox' view |
|
24 |
||
25 |
:label: |
|
26 |
label for the relations section or side box |
|
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
27 |
|
1739 | 28 |
:limit: |
29 |
boolean telling if the results should be limited according to the |
|
30 |
configuration |
|
31 |
||
32 |
:filter: |
|
33 |
callback taking the related result set as argument and returning it |
|
34 |
filtered |
|
35 |
||
36 |
:order: |
|
37 |
int used to control order within a section. When not specified, |
|
38 |
automatically set according to order in which tags are added. |
|
39 |
||
40 |
Notice those values are only considered if the relation is in a displayed |
|
41 |
section (controlled by :attr:`primaryview_section`) |
|
42 |
||
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
43 |
|
1739 | 44 |
Index view configuration |
45 |
```````````````````````` |
|
46 |
:indexview_etype_section: |
|
47 |
entity type category in the index/manage page. May be one of |
|
48 |
* 'application' |
|
49 |
* 'system' |
|
50 |
* 'schema' |
|
51 |
* 'subobject' (not displayed by default) |
|
52 |
||
53 |
||
54 |
Actions box configuration |
|
55 |
````````````````````````` |
|
56 |
:actionbox_appearsin_addmenu: |
|
57 |
simple boolean relation tags used to control the "add entity" submenu. |
|
58 |
Relations whose rtag is True will appears, other won't. |
|
59 |
||
60 |
Automatic form configuration |
|
61 |
```````````````````````````` |
|
62 |
||
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
63 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
64 |
:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
65 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
66 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
67 |
""" |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
68 |
__docformat__ = "restructuredtext en" |
1533 | 69 |
|
3057
f4ba5a251ab7
generic rtag cleaing method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
70 |
from cubicweb import neg_role |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
71 |
from cubicweb.rtags import (RelationTags, RelationTagsBool, |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
72 |
RelationTagsSet, RelationTagsDict) |
1739 | 73 |
from cubicweb.web import formwidgets |
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
|
1745
7e7f04d19a98
a bunch of NameError (!) // needs review //
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1742
diff
changeset
|
75 |
|
1746
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
76 |
def card_from_role(card, role): |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
77 |
if role == 'subject': |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
78 |
return card[0] |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
79 |
assert role in ('object', 'sobject'), repr(role) |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
80 |
return card[1] |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
81 |
|
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
82 |
# primary view configuration ################################################## |
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
83 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
84 |
def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
85 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1746
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
86 |
card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role) |
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
87 |
composed = rschema.rproperty(sschema, oschema, 'composite') == neg_role(role) |
1739 | 88 |
if rschema.is_final(): |
2671
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
89 |
if rschema.meta or sschema.is_metadata(rschema) \ |
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
90 |
or oschema.type in ('Password', 'Bytes'): |
1739 | 91 |
section = 'hidden' |
92 |
else: |
|
93 |
section = 'attributes' |
|
94 |
elif card in '1+': |
|
95 |
section = 'attributes' |
|
96 |
elif composed: |
|
97 |
section = 'relations' |
|
98 |
else: |
|
99 |
section = 'sideboxes' |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
100 |
rtag.tag_relation((sschema, rschema, oschema, role), section) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
101 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
102 |
primaryview_section = RelationTags('primaryview_section', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
103 |
init_primaryview_section, |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
104 |
frozenset(('attributes', 'relations', |
1739 | 105 |
'sideboxes', 'hidden'))) |
106 |
||
107 |
||
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
108 |
class DisplayCtrlRelationTags(RelationTagsDict): |
1739 | 109 |
def __init__(self, *args, **kwargs): |
110 |
super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs) |
|
111 |
self._counter = 0 |
|
112 |
||
113 |
def tag_relation(self, key, tag): |
|
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
114 |
tag = super(DisplayCtrlRelationTags, self).tag_relation(key, tag) |
1739 | 115 |
self._counter += 1 |
116 |
tag.setdefault('order', self._counter) |
|
117 |
||
2191
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
118 |
def tag_subject_of(self, key, tag): |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
119 |
subj, rtype, obj = key |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
120 |
if obj != '*': |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
121 |
self.warning('using explict target type in display_ctrl.tag_subject_of() ' |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
122 |
'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)', |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
123 |
subj, rtype, subj, rtype, obj) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
124 |
super(DisplayCtrlRelationTags, self).tag_subject_of((subj, rtype, '*'), tag) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
125 |
|
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
126 |
def tag_object_of(self, key, tag): |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
127 |
subj, rtype, obj = key |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
128 |
if subj != '*': |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
129 |
self.warning('using explict subject type in display_ctrl.tag_object_of() ' |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
130 |
'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)', |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
131 |
rtype, obj, subj, rtype, obj) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
132 |
super(DisplayCtrlRelationTags, self).tag_object_of(('*', rtype, obj), tag) |
1739 | 133 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
134 |
def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role): |
1739 | 135 |
if role == 'subject': |
136 |
oschema = '*' |
|
137 |
label = rschema.type |
|
138 |
else: |
|
139 |
sschema = '*' |
|
140 |
label = '%s_%s' % (rschema, role) |
|
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
141 |
rtag.setdefault((sschema, rschema, oschema, role), 'label', label) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
142 |
rtag.setdefault((sschema, rschema, oschema, role), 'order', rtag._counter) |
1739 | 143 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
144 |
primaryview_display_ctrl = DisplayCtrlRelationTags('primaryview_display_ctrl', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
145 |
init_primaryview_display_ctrl) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
146 |
|
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
147 |
# index view configuration #################################################### |
1739 | 148 |
# entity type section in the index/manage page. May be one of |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
149 |
# * 'application' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
150 |
# * 'system' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
151 |
# * 'schema' |
2951
d0b77dd27740
[wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
152 |
# * 'hidden' |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
153 |
# * 'subobject' (not displayed by default) |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
154 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
155 |
indexview_etype_section = {'EmailAddress': 'subobject', |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
156 |
'CWUser': 'system', |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
157 |
'CWGroup': 'system', |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
158 |
'CWPermission': 'system', |
2951
d0b77dd27740
[wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
159 |
'BaseTransition': 'hidden', |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
160 |
} |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
161 |
|
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
162 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1468
diff
changeset
|
163 |
# autoform.AutomaticEntityForm configuration ################################## |
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
164 |
|
1739 | 165 |
# relations'section (eg primary/secondary/generic/metadata/generated) |
166 |
||
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
167 |
def init_autoform_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
168 |
if rtag.get(sschema, rschema, oschema, role) is None: |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
169 |
if autoform_is_inlined.get(sschema, rschema, oschema, role): |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
170 |
section = 'generated' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
171 |
elif sschema.is_metadata(rschema): |
2505
5d7d4af9eadf
fix some default autoform_section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2465
diff
changeset
|
172 |
section = 'metadata' |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
173 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
174 |
if role == 'subject': |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
175 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
176 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
1739 | 177 |
else: |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
178 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
179 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
180 |
if card in '1+': |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
181 |
if not rschema.is_final() and composed: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
182 |
# XXX why? probably because we want it unlined, though this |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
183 |
# is not the case by default |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
184 |
section = 'generated' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
185 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
186 |
section = 'primary' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
187 |
elif rschema.is_final(): |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
188 |
section = 'secondary' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
189 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
190 |
section = 'generic' |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
191 |
rtag.tag_relation((sschema, rschema, oschema, role), section) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
192 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
193 |
autoform_section = RelationTags('autoform_section', init_autoform_section, |
1739 | 194 |
set(('primary', 'secondary', 'generic', |
195 |
'metadata', 'generated'))) |
|
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
196 |
|
1313
9cff1eee0208
put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
197 |
# relations'field class |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
198 |
autoform_field = RelationTags('autoform_field') |
1313
9cff1eee0208
put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
199 |
|
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1747
diff
changeset
|
200 |
# relations'field explicit kwargs (given to field's __init__) |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
201 |
autoform_field_kwargs = RelationTagsDict() |
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
202 |
|
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
203 |
# inlined view flag for non final relations: when True for an entry, the |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
204 |
# entity(ies) at the other end of the relation will be editable from the |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
205 |
# form of the edited entity |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
206 |
autoform_is_inlined = RelationTagsBool('autoform_is_inlined') |
1604 | 207 |
|
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
208 |
|
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
209 |
# set of tags of the form <action>_on_new on relations. <action> is a |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
210 |
# schema action (add/update/delete/read), and when such a tag is found |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
211 |
# permissions checking is by-passed and supposed to be ok |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
212 |
autoform_permissions_overrides = RelationTagsSet('autoform_permissions_overrides') |
1285
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
213 |
|
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
214 |
# boxes.EditBox configuration ################################################# |
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
215 |
|
d5ce82d65c2b
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
216 |
# 'link' / 'create' relation tags, used to control the "add entity" submenu |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
217 |
def init_actionbox_appearsin_addmenu(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
218 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1739 | 219 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[role == 'object'] |
220 |
if not card in '?1' and \ |
|
221 |
rschema.rproperty(sschema, oschema, 'composite') == role: |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
222 |
rtag.tag_relation((sschema, rschema, oschema, role), True) |
1739 | 223 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
224 |
actionbox_appearsin_addmenu = RelationTagsBool('actionbox_appearsin_addmenu', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
225 |
init_actionbox_appearsin_addmenu) |