author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 14 Apr 2010 16:57:55 +0200 | |
branch | stable |
changeset 5258 | 9ff357e82e36 |
parent 5227 | ed1c138299f2 |
child 5265 | 97ab2ea6d367 |
permissions | -rw-r--r-- |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
1 |
#:organization: Logilab |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
2 |
#:copyright: 2009-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
3 |
#:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
4 |
#:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
5 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
6 |
"""This module (``cubicweb.web.uicfg``) regroups a set of structures that may be used to configure |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
7 |
various options of the generated web interface. |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
8 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
9 |
To configure the interface generation, we use ``RelationTag`` objects. |
1739 | 10 |
|
11 |
Primary view configuration |
|
12 |
`````````````````````````` |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
13 |
|
5227
ed1c138299f2
[doc/book] primary view section enhancements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5142
diff
changeset
|
14 |
XXX section moved to the doc, is maintained there |
ed1c138299f2
[doc/book] primary view section enhancements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5142
diff
changeset
|
15 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
16 |
If you want to customize the primary view of an entity, overriding the primary |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
17 |
view class may not be necessary. For simple adjustments (attributes or relations |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
18 |
display locations and styles), a much simpler way is to use uicfg. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
19 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
20 |
Attributes/relations display location |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
21 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
22 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
23 |
In the primary view, there are 3 sections where attributes and relations can be |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
24 |
displayed (represented in pink in the image below): |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
25 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
26 |
* attributes |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
27 |
* relations |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
28 |
* sideboxes |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
29 |
|
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4931
diff
changeset
|
30 |
.. image:: ../../images/primaryview_template.png |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
31 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
32 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
33 |
**Attributes** can only be displayed in the attributes section (default |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
34 |
behavior). They can also be hidden. |
1739 | 35 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
36 |
For instance, to hide the ``title`` attribute of the ``Blog`` entity: |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
37 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
38 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
39 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
40 |
from cubicweb.web import uicfg |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
41 |
uicfg.primaryview_section.tag_attribute(('Blog', 'title'), 'hidden') |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
42 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
43 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
44 |
**Relations** can be either displayed in one of the three sections or hidden. |
1739 | 45 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
46 |
For relations, there are two methods: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
47 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
48 |
* ``tag_object_of`` for modifying the primary view of the object |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
49 |
* ``tag_subject_of`` for modifying the primary view of the subject |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
50 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
51 |
These two methods take two arguments: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
52 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
53 |
* a triplet ``(subject, relation_name, object)``, where subject or object can be replaced with ``'*'`` |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
54 |
* the section name or ``hidden`` |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
55 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
56 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
57 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
58 |
# hide every relation ``entry_of`` in the ``Blog`` primary view |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
59 |
uicfg.primaryview_section.tag_object_of(('*', 'entry_of', 'Blog'), 'hidden') |
1739 | 60 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
61 |
# display ``entry_of`` relations in the ``relations`` section in the ``BlogEntry`` primary view |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
62 |
uicfg.primaryview_section.tag_subject_of(('BlogEntry', 'entry_of', '*'), |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
63 |
'relations') |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
64 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
65 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
66 |
Display content |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
67 |
^^^^^^^^^^^^^^^ |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
68 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
69 |
You can use ``primaryview_display_ctrl`` to customize the display of attributes |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
70 |
or relations. Values of ``primaryview_display_ctrl`` are dictionaries. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
71 |
|
1739 | 72 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
73 |
Common keys for attributes and relations are: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
74 |
* ``vid``: specifies the regid of the view for displaying the attribute or the relation. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
75 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
76 |
If ``vid`` is not specified, the default value depends on the section: |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
77 |
* ``attributes`` section: 'reledit' view |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
78 |
* ``relations`` section: 'autolimited' view |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
79 |
* ``sideboxes`` section: 'sidebox' view |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
80 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
81 |
* ``order``: int used to control order within a section. When not specified, |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
82 |
automatically set according to order in which tags are added. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
83 |
|
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
|
84 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
85 |
Keys for relations only: |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
86 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
87 |
* ``label``: label for the relations section or side box |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
88 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
89 |
* ``showlabel``: boolean telling whether the label is displayed |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
90 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
91 |
* ``limit``: boolean telling if the results should be limited. If so, a link to all results is displayed |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
92 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
93 |
* ``filter``: callback taking the related result set as argument and returning it filtered |
1739 | 94 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
95 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
96 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
97 |
# in ``CWUser`` primary view, display ``created_by`` relations in relations section |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
98 |
uicfg.primaryview_section.tag_object_of(('*', 'created_by', 'CWUser'), 'relations') |
1739 | 99 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
100 |
# displays this relation as a list, sets the label, limits the number of results and filters on comments |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
101 |
uicfg.primaryview_display_ctrl.tag_object_of( |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
102 |
('*', 'created_by', 'CWUser'), |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
103 |
{'vid': 'list', 'label': _('latest comment(s):'), 'limit': True, |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
104 |
'filter': lambda rset: rset.filtered_rset(lambda x: x.e_schema == 'Comment')}) |
1739 | 105 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
106 |
.. Warning:: with the ``primaryview_display_ctrl`` rtag, the subject or the |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
107 |
object of the relation is ignored for respectively ``tag_object_of`` or |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
108 |
``tag_subject_of``. To avoid warnings during execution, they should be set to |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
109 |
``'*'``. |
1739 | 110 |
|
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
|
111 |
|
1739 | 112 |
Index view configuration |
113 |
```````````````````````` |
|
114 |
:indexview_etype_section: |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
115 |
entity type category in the index/manage page. May be one of: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
116 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
117 |
* ``application`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
118 |
* ``system`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
119 |
* ``schema`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
120 |
* ``subobject`` (not displayed by default) |
1739 | 121 |
|
122 |
||
123 |
Actions box configuration |
|
124 |
````````````````````````` |
|
125 |
:actionbox_appearsin_addmenu: |
|
126 |
simple boolean relation tags used to control the "add entity" submenu. |
|
127 |
Relations whose rtag is True will appears, other won't. |
|
128 |
||
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
129 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
130 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
131 |
# Adds all subjects of the entry_of relation in the add menu of the ``Blog`` primary view |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
132 |
uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True) |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
133 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
134 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
135 |
|
1739 | 136 |
Automatic form configuration |
137 |
```````````````````````````` |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
138 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
139 |
Attributes/relations display location |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
140 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
141 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
142 |
``uicfg.autoform_section`` specifies where to display a relation in |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
143 |
creation/edition entity form for a given form type. ``tag_attribute``, |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
144 |
``tag_subject_of`` and ``tag_object_of`` methods for this relation tag expect |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
145 |
two arguments additionally to the relation key: a ``formtype`` and a |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
146 |
``section``. |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
147 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
148 |
formtype may be one of: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
149 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
150 |
* ``main``, the main entity form (via the modify action) |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
151 |
* ``inlined``, the form for an entity inlined into another form |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
152 |
* ``muledit``, the table form to edit multiple entities |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
153 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
154 |
section may be one of: |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
155 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
156 |
* ``hidden``, don't display |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
157 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
158 |
* ``attributes``, display in the attributes section |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
159 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
160 |
* ``relations``, display in the relations section, using the generic relation |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
161 |
selector combobox (available in main form only, and not for attribute |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
162 |
relation) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
163 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
164 |
* ``inlined``, display target entity of the relation in an inlined form |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
165 |
(available in main form only, and not for attribute relation) |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
166 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
167 |
* ``metadata``, display in a special metadata form (NOT YET IMPLEMENTED, subject |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
168 |
to changes) |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
169 |
|
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
170 |
By default, mandatory relations are displayed in the ``attributes`` section, |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
171 |
others in ``relations`` section. |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
172 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
173 |
Change default fields |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
174 |
^^^^^^^^^^^^^^^^^^^^^ |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
175 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
176 |
Use ``autoform_field`` to replace the default field type of an attribute. |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
177 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
178 |
.. Warning: |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
179 |
``autoform_field_kwargs`` should usually be used instead of |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
180 |
``autoform_field``. Do not use both methods for the same relation! |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
181 |
|
1739 | 182 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
183 |
Customize field options |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
184 |
^^^^^^^^^^^^^^^^^^^^^^^ |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
185 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
186 |
In order to customize field options (see :class:`cubicweb.web.formfields.Field` |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
187 |
for a detailed list of options), use ``autoform_field_kwargs``. This rtag takes |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
188 |
a relation triplet and a dictionary as arguments. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
189 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
190 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
191 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
192 |
# Change the content of the combobox |
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
193 |
# here ``ticket_done_in_choices`` is a function which returns a list of |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
194 |
# elements to populate the combobox |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
195 |
uicfg.autoform_field_kwargs.tag_subject_of(('Ticket', 'done_in', '*'), {'sort': False, |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
196 |
'choices': ticket_done_in_choices}) |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
197 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
198 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
199 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
200 |
Overriding permissions |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
201 |
^^^^^^^^^^^^^^^^^^^^^^ |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
202 |
|
5142
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
203 |
``autoform_permissions_overrides`` provides a way to by-pass security checking |
0aa4d348c2e6
fix rest formatting
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4936
diff
changeset
|
204 |
for dark-corner case where it can't be verified properly. XXX documents. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
205 |
|
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
|
206 |
""" |
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
|
207 |
__docformat__ = "restructuredtext en" |
1533 | 208 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
209 |
from warnings import warn |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
210 |
|
4521
32402dd2504d
missing import for 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4397
diff
changeset
|
211 |
from logilab.common.compat import any |
32402dd2504d
missing import for 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4397
diff
changeset
|
212 |
|
3057
f4ba5a251ab7
generic rtag cleaing method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
213 |
from cubicweb import neg_role |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
214 |
from cubicweb.rtags import (RelationTags, RelationTagsBool, RelationTagsSet, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
215 |
RelationTagsDict, register_rtag, _ensure_str_key) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
216 |
from cubicweb.schema import META_RTYPES |
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
|
217 |
|
1745
7e7f04d19a98
a bunch of NameError (!) // needs review //
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1742
diff
changeset
|
218 |
|
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
219 |
# primary view configuration ################################################## |
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
220 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
221 |
def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
222 |
if rtag.get(sschema, rschema, oschema, role) is None: |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
223 |
rdef = rschema.rdef(sschema, oschema) |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3597
diff
changeset
|
224 |
if rschema.final: |
2671
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
225 |
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
|
226 |
or oschema.type in ('Password', 'Bytes'): |
1739 | 227 |
section = 'hidden' |
228 |
else: |
|
229 |
section = 'attributes' |
|
230 |
else: |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
231 |
if rdef.role_cardinality(role) in '1+': |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
232 |
section = 'attributes' |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
233 |
elif rdef.composite == neg_role(role): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
234 |
section = 'relations' |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
235 |
else: |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
236 |
section = 'sideboxes' |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
237 |
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
|
238 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
239 |
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
|
240 |
init_primaryview_section, |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
241 |
frozenset(('attributes', 'relations', |
1739 | 242 |
'sideboxes', 'hidden'))) |
243 |
||
244 |
||
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
245 |
class DisplayCtrlRelationTags(RelationTagsDict): |
1739 | 246 |
def __init__(self, *args, **kwargs): |
247 |
super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs) |
|
248 |
self._counter = 0 |
|
249 |
||
250 |
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
|
251 |
tag = super(DisplayCtrlRelationTags, self).tag_relation(key, tag) |
1739 | 252 |
self._counter += 1 |
253 |
tag.setdefault('order', self._counter) |
|
254 |
||
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
'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
|
260 |
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
|
261 |
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
|
262 |
|
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
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
'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
|
268 |
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
|
269 |
super(DisplayCtrlRelationTags, self).tag_object_of(('*', rtype, obj), tag) |
1739 | 270 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
271 |
def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role): |
1739 | 272 |
if role == 'subject': |
273 |
oschema = '*' |
|
274 |
label = rschema.type |
|
275 |
else: |
|
276 |
sschema = '*' |
|
277 |
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
|
278 |
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
|
279 |
rtag.setdefault((sschema, rschema, oschema, role), 'order', rtag._counter) |
1739 | 280 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
281 |
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
|
282 |
init_primaryview_display_ctrl) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
283 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
284 |
|
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
285 |
# index view configuration #################################################### |
1739 | 286 |
# 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
|
287 |
# * 'application' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
288 |
# * 'system' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
289 |
# * 'schema' |
2951
d0b77dd27740
[wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
290 |
# * 'hidden' |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
291 |
# * 'subobject' (not displayed by default) |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
292 |
|
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
|
293 |
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
|
294 |
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
|
295 |
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
|
296 |
register_rtag(self) |
4355
b50dd952cb8d
[uicfg] fix reloading pb with the indexview_etype_section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4347
diff
changeset
|
297 |
self.__defaults = dict(self) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
298 |
|
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
299 |
def init(self, schema, check=True): |
4355
b50dd952cb8d
[uicfg] fix reloading pb with the indexview_etype_section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4347
diff
changeset
|
300 |
self.update(self.__defaults) |
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
|
301 |
for eschema in schema.entities(): |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
302 |
if eschema.final: |
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
303 |
continue |
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
|
304 |
if eschema.schema_entity(): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
305 |
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
|
306 |
elif eschema.is_subobject(strict=True): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
307 |
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
|
308 |
else: |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
309 |
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
|
310 |
|
4356
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
311 |
indexview_etype_section = InitializableDict( |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
312 |
EmailAddress='subobject', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
313 |
# entity types in the 'system' table by default (managers only) |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
314 |
CWUser='system', CWGroup='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
315 |
CWPermission='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
316 |
CWCache='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
317 |
Workflow='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
318 |
ExternalUri='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
319 |
Bookmark='system', |
8496a79aed0a
[uicfg] clean dead code, fix indexview_etype_section for ExternalUri and Bookmark
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4355
diff
changeset
|
320 |
) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
321 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1468
diff
changeset
|
322 |
# 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
|
323 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
324 |
def _formsections_as_dict(formsections): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
325 |
result = {} |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
326 |
for formsection in formsections: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
327 |
formtype, section = formsection.split('_', 1) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
328 |
result[formtype] = section |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
329 |
return result |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
330 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
331 |
def _card_and_comp(sschema, rschema, oschema, role): |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
332 |
rdef = rschema.rdef(sschema, oschema) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
333 |
if role == 'subject': |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
334 |
card = rdef.cardinality[0] |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
335 |
composed = not rschema.final and rdef.composite == 'object' |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
336 |
else: |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
337 |
card = rdef.cardinality[1] |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
338 |
composed = not rschema.final and rdef.composite == 'subject' |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
339 |
return card, composed |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
340 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
341 |
class AutoformSectionRelationTags(RelationTagsSet): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
342 |
"""autoform relations'section""" |
1739 | 343 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
344 |
bw_tag_map = { |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
345 |
'primary': {'main': 'attributes', 'muledit': 'attributes'}, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
346 |
'secondary': {'main': 'attributes', 'muledit': 'hidden'}, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
347 |
'metadata': {'main': 'metadata'}, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
348 |
'generic': {'main': 'relations'}, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
349 |
'generated': {'main': 'hidden'}, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
350 |
} |
1739 | 351 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
352 |
_allowed_form_types = ('main', 'inlined', 'muledit') |
3656
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
353 |
_allowed_values = {'main': ('attributes', 'inlined', 'relations', |
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
354 |
'metadata', 'hidden'), |
4698
9bd98fc7ef3d
[uicfg] section='inlined' is acceptable for inlined forms
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4607
diff
changeset
|
355 |
'inlined': ('attributes', 'inlined', 'hidden'), |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
356 |
'muledit': ('attributes', 'hidden'), |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
357 |
} |
1739 | 358 |
|
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
359 |
def init(self, schema, check=True): |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
360 |
super(AutoformSectionRelationTags, self).init(schema, check) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
361 |
self.apply(schema, self._initfunc_step2) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
362 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
363 |
@staticmethod |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
364 |
def _initfunc(self, sschema, rschema, oschema, role): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
365 |
formsections = self.init_get(sschema, rschema, oschema, role) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
366 |
if formsections is None: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
367 |
formsections = self.tag_container_cls() |
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
368 |
if not any(tag.startswith('inlined') for tag in formsections): |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
369 |
if not rschema.final: |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
370 |
negsects = self.init_get(sschema, rschema, oschema, neg_role(role)) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
371 |
if 'main_inlined' in negsects: |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
372 |
formsections.add('inlined_hidden') |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
373 |
key = _ensure_str_key( (sschema, rschema, oschema, role) ) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
374 |
self._tagdefs[key] = formsections |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
375 |
|
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
376 |
@staticmethod |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
377 |
def _initfunc_step2(self, sschema, rschema, oschema, role): |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
378 |
formsections = self.get(sschema, rschema, oschema, role) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
379 |
sectdict = _formsections_as_dict(formsections) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
380 |
if rschema in META_RTYPES: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
381 |
sectdict.setdefault('main', 'hidden') |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
382 |
sectdict.setdefault('muledit', 'hidden') |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
383 |
sectdict.setdefault('inlined', 'hidden') |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
384 |
# ensure we have a tag for each form type |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
385 |
if not 'main' in sectdict: |
3729
e4f20b74af51
remove some warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
386 |
if not rschema.final and ( |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
387 |
sectdict.get('inlined') == 'attributes' or |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
388 |
'inlined_attributes' in self.init_get(sschema, rschema, oschema, |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
389 |
neg_role(role))): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
390 |
sectdict['main'] = 'hidden' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
391 |
elif sschema.is_metadata(rschema): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
392 |
sectdict['main'] = 'metadata' |
1739 | 393 |
else: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
394 |
card, composed = _card_and_comp(sschema, rschema, oschema, role) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
395 |
if card in '1+': |
3629 | 396 |
sectdict['main'] = 'attributes' |
397 |
if not 'muledit' in sectdict: |
|
398 |
sectdict['muledit'] = 'attributes' |
|
3729
e4f20b74af51
remove some warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
399 |
elif rschema.final: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
400 |
sectdict['main'] = 'attributes' |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
401 |
else: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
402 |
sectdict['main'] = 'relations' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
403 |
if not 'muledit' in sectdict: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
404 |
sectdict['muledit'] = 'hidden' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
405 |
if sectdict['main'] == 'attributes': |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
406 |
card, composed = _card_and_comp(sschema, rschema, oschema, role) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
407 |
if card in '1+' and not composed: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
408 |
sectdict['muledit'] = 'attributes' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
409 |
if not 'inlined' in sectdict: |
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
410 |
sectdict['inlined'] = sectdict['main'] |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
411 |
# recompute formsections and set it to avoid recomputing |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
412 |
for formtype, section in sectdict.iteritems(): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
413 |
formsections.add('%s_%s' % (formtype, section)) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
414 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
415 |
def tag_relation(self, key, formtype, section=None): |
4564
38f0562b744b
[uicfg] allow autoform_section's formtype parameter to be a tuple
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4521
diff
changeset
|
416 |
if isinstance(formtype, tuple): |
38f0562b744b
[uicfg] allow autoform_section's formtype parameter to be a tuple
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4521
diff
changeset
|
417 |
for ftype in formtype: |
38f0562b744b
[uicfg] allow autoform_section's formtype parameter to be a tuple
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4521
diff
changeset
|
418 |
self.tag_relation(key, ftype, section) |
38f0562b744b
[uicfg] allow autoform_section's formtype parameter to be a tuple
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4521
diff
changeset
|
419 |
return |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
420 |
if section is None: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
421 |
tag = formtype |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
422 |
for formtype, section in self.bw_tag_map[tag].iteritems(): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
423 |
warn('[3.6] add tag to autoform section by specifying form ' |
4146 | 424 |
'type and tag. Replace %s by formtype="%s", section="%s"' |
3656
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
425 |
% (tag, formtype, section), DeprecationWarning, |
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
426 |
stacklevel=3) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
427 |
self.tag_relation(key, formtype, section) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
428 |
assert formtype in self._allowed_form_types, \ |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
429 |
'formtype should be in (%s), not %s' % ( |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
430 |
','.join(self._allowed_form_types), formtype) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
431 |
assert section in self._allowed_values[formtype], \ |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
432 |
'section for %s should be in (%s), not %s' % ( |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
433 |
formtype, ','.join(self._allowed_values[formtype]), section) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
434 |
rtags = self._tagdefs.setdefault(_ensure_str_key(key), |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
435 |
self.tag_container_cls()) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
436 |
# remove previous section for this form type if any |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
437 |
if rtags: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
438 |
for tag in rtags.copy(): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
439 |
if tag.startswith(formtype): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
440 |
rtags.remove(tag) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
441 |
rtags.add('%s_%s' % (formtype, section)) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
442 |
return rtags |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
443 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
444 |
def init_get(self, *key): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
445 |
return super(AutoformSectionRelationTags, self).get(*key) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
446 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
447 |
def get(self, *key): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
448 |
# overriden to avoid recomputing done in parent classes |
4397
fbac86ca7af1
should not raise KeyError if key's missing
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4364
diff
changeset
|
449 |
return self._tagdefs.get(key, ()) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
450 |
|
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
451 |
def relations_by_section(self, entity, formtype, section, permission, |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
452 |
strict=False): |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
453 |
"""return a list of (relation schema, target schemas, role) for the |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
454 |
given entity matching categories and permission. |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
455 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
456 |
`strict`: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
457 |
bool telling if having local role is enough (strict = False) or not |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
458 |
""" |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
459 |
tag = '%s_%s' % (formtype, section) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
460 |
eschema = entity.e_schema |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
461 |
permsoverrides = autoform_permissions_overrides |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
462 |
if entity.has_eid(): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
463 |
eid = entity.eid |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
464 |
else: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
465 |
eid = None |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
466 |
strict = False |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
467 |
if permission == 'update': |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
468 |
assert section in ('attributes', 'metadata', 'hidden') |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
469 |
relpermission = 'add' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
470 |
else: |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
471 |
assert section not in ('attributes', 'metadata', 'hidden') |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
472 |
relpermission = permission |
4072
ead446e70c28
some api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4015
diff
changeset
|
473 |
cw = entity._cw |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
474 |
for rschema, targetschemas, role in eschema.relation_definitions(True): |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
475 |
_targetschemas = [] |
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
476 |
for tschema in targetschemas: |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
477 |
# check section's tag first, potentially lower cost than |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
478 |
# checking permission which may imply rql queries |
4007
91d11fda4aa0
more api renaming/fixing update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
4003
diff
changeset
|
479 |
if not tag in self.etype_get(eschema, rschema, role, tschema): |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
480 |
continue |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
481 |
rdef = rschema.role_rdef(eschema, tschema, role) |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
482 |
if rschema.final: |
4607
55eab66c6592
[schema security] fix so that when cheking attributes perms for an entity being created, 'owners' and has_*_permission in erqlexpr are considered satisfied
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
483 |
if not rdef.has_perm(cw, permission, eid=eid, |
55eab66c6592
[schema security] fix so that when cheking attributes perms for an entity being created, 'owners' and has_*_permission in erqlexpr are considered satisfied
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4570
diff
changeset
|
484 |
creating=eid is None): |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
485 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
486 |
elif strict or not rdef.has_local_role(relpermission): |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
487 |
if role == 'subject': |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
488 |
if not rdef.has_perm(cw, relpermission, fromeid=eid): |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
489 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
490 |
elif role == 'object': |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
491 |
if not rdef.has_perm(cw, relpermission, toeid=eid): |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
492 |
continue |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
493 |
_targetschemas.append(tschema) |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
494 |
if not _targetschemas: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
495 |
continue |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
496 |
targetschemas = _targetschemas |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
497 |
rdef = eschema.rdef(rschema, role=role, targettype=targetschemas[0]) |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
498 |
# XXX tag allowing to hijack the permission machinery when |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
499 |
# permission is not verifiable until the entity is actually |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
500 |
# created... |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
501 |
if eid is None and '%s_on_new' % permission in permsoverrides.etype_get(eschema, rschema, role): |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
502 |
yield (rschema, targetschemas, role) |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
503 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
504 |
if not rschema.final and role == 'subject': |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
505 |
# on relation with cardinality 1 or ?, we need delete perm as well |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
506 |
# if the relation is already set |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
507 |
if (relpermission == 'add' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
508 |
and rdef.role_cardinality(role) in '1?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
509 |
and eid and entity.related(rschema.type, role) |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
510 |
and not rdef.has_perm(cw, 'delete', fromeid=eid, |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
511 |
toeid=entity.related(rschema.type, role)[0][0])): |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
512 |
continue |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
513 |
elif role == 'object': |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
514 |
# on relation with cardinality 1 or ?, we need delete perm as well |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
515 |
# if the relation is already set |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
516 |
if (relpermission == 'add' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
517 |
and rdef.role_cardinality(role) in '1?' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
518 |
and eid and entity.related(rschema.type, role) |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
519 |
and not rdef.has_perm(cw, 'delete', toeid=eid, |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
520 |
fromeid=entity.related(rschema.type, role)[0][0])): |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
521 |
continue |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
522 |
yield (rschema, targetschemas, role) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
523 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
524 |
autoform_section = AutoformSectionRelationTags('autoform_section') |
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
|
525 |
|
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
|
526 |
# 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
|
527 |
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
|
528 |
|
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1747
diff
changeset
|
529 |
# 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
|
530 |
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
|
531 |
|
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
|
532 |
|
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
|
533 |
# 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
|
534 |
# 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
|
535 |
# 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
|
536 |
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
|
537 |
|
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
|
538 |
# 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
|
539 |
|
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
|
540 |
# '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
|
541 |
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
|
542 |
if rtag.get(sschema, rschema, oschema, role) is None: |
3480
370d20fec445
smarter default for actionbox_appearsin_addmenu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3476
diff
changeset
|
543 |
if rschema in META_RTYPES: |
370d20fec445
smarter default for actionbox_appearsin_addmenu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3476
diff
changeset
|
544 |
rtag.tag_relation((sschema, rschema, oschema, role), False) |
370d20fec445
smarter default for actionbox_appearsin_addmenu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3476
diff
changeset
|
545 |
return |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
546 |
rdef = rschema.rdef(sschema, oschema) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
547 |
if not rdef.role_cardinality(role) in '?1' and rdef.composite == role: |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
548 |
rtag.tag_relation((sschema, rschema, oschema, role), True) |
1739 | 549 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
550 |
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
|
551 |
init_actionbox_appearsin_addmenu) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
552 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
553 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
554 |
# deprecated ################################################################### |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
555 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
556 |
class AutoformIsInlined(RelationTags): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
557 |
"""XXX for < 3.6 bw compat""" |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
558 |
def tag_relation(self, key, tag): |
4565
9f991ee66e19
[uicfg] make deprecation message easier to understand
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4564
diff
changeset
|
559 |
warn('autoform_is_inlined is deprecated, use autoform_section ' |
4782
da0ad1b10779
le patch fix-3.6-deprecation-warning a été importé
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4719
diff
changeset
|
560 |
'with formtype="main", section="inlined"', |
4339
fe93b670343d
some fixes so that deprecation warning are properly localized
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4261
diff
changeset
|
561 |
DeprecationWarning, stacklevel=3) |
4261
b45a3563c6bb
fix autoform_is_inlined bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
562 |
section = tag and 'inlined' or 'hidden' |
b45a3563c6bb
fix autoform_is_inlined bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
563 |
autoform_section.tag_relation(key, 'main', section) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
564 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
565 |
# inlined view flag for non final relations: when True for an entry, the |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
566 |
# entity(ies) at the other end of the relation will be editable from the |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
567 |
# form of the edited entity |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
568 |
autoform_is_inlined = AutoformIsInlined('autoform_is_inlined') |