author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 18 Aug 2009 09:25:26 +0200 | |
changeset 2901 | 8f4d495c94c2 |
parent 2806 | 9d7173656a1a |
child 2968 | 0e3460341023 |
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 |
|
2689
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
70 |
from cubicweb import neg_role, onevent |
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, |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
72 |
RelationTagsSet, RelationTagsDict, register_rtag) |
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' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
152 |
# * 'subobject' (not displayed by default) |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
153 |
|
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
154 |
class InitializableDict(dict): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
155 |
def __init__(self, *args, **kwargs): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
156 |
super(InitializableDict, self).__init__(*args, **kwargs) |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
157 |
register_rtag(self) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
158 |
|
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
159 |
def init(self, schema, check=True): |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
160 |
for eschema in schema.entities(): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
161 |
if eschema.schema_entity(): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
162 |
self.setdefault(eschema, 'schema') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
163 |
elif eschema.is_subobject(strict=True): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
164 |
self.setdefault(eschema, 'subobject') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
165 |
else: |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
166 |
self.setdefault(eschema, 'application') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
167 |
|
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
168 |
indexview_etype_section = InitializableDict(EmailAddress='subobject', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
169 |
CWUser='system', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
170 |
CWGroup='system', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
171 |
CWPermission='system', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
172 |
) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
173 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1468
diff
changeset
|
174 |
# 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
|
175 |
|
1739 | 176 |
# relations'section (eg primary/secondary/generic/metadata/generated) |
177 |
||
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
178 |
def init_autoform_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
179 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1739 | 180 |
if role == 'subject': |
181 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
|
182 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
|
183 |
else: |
|
184 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
|
185 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
|
186 |
if sschema.is_metadata(rschema): |
|
2505
5d7d4af9eadf
fix some default autoform_section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2465
diff
changeset
|
187 |
section = 'metadata' |
1739 | 188 |
elif card in '1+': |
189 |
if not rschema.is_final() and composed: |
|
190 |
section = 'generated' |
|
191 |
else: |
|
192 |
section = 'primary' |
|
193 |
elif rschema.is_final(): |
|
194 |
section = 'secondary' |
|
195 |
else: |
|
196 |
section = 'generic' |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
197 |
rtag.tag_relation((sschema, rschema, oschema, role), section) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
198 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
199 |
autoform_section = RelationTags('autoform_section', init_autoform_section, |
1739 | 200 |
set(('primary', 'secondary', 'generic', |
201 |
'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
|
202 |
|
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
|
203 |
# 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
|
204 |
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
|
205 |
|
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1747
diff
changeset
|
206 |
# 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
|
207 |
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
|
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 |
# 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
|
210 |
# 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
|
211 |
# 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
|
212 |
autoform_is_inlined = RelationTagsBool('autoform_is_inlined') |
1604 | 213 |
|
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
|
214 |
|
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 |
# 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
|
216 |
# 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
|
217 |
# 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
|
218 |
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
|
219 |
|
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
|
220 |
# 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
|
221 |
|
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
|
222 |
# '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
|
223 |
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
|
224 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1739 | 225 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[role == 'object'] |
226 |
if not card in '?1' and \ |
|
227 |
rschema.rproperty(sschema, oschema, 'composite') == role: |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
228 |
rtag.tag_relation((sschema, rschema, oschema, role), True) |
1739 | 229 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
230 |
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
|
231 |
init_actionbox_appearsin_addmenu) |
1878
204b79e3e0ec
default email relations configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1849
diff
changeset
|
232 |
|
2705
30bcdbd92820
[events] renamed source-reload into registry-reload to avoid potential confusions with datasources
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2703
diff
changeset
|
233 |
@onevent('before-registry-reload') |
2689
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
234 |
def clear_rtag_objects(): |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
235 |
primaryview_section.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
236 |
primaryview_display_ctrl.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
237 |
autoform_section.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
238 |
autoform_field.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
239 |
autoform_field_kwargs.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
240 |
autoform_is_inlined.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
241 |
autoform_permissions_overrides.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2671
diff
changeset
|
242 |
actionbox_appearsin_addmenu.clear() |