author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Mon, 20 Sep 2010 15:50:12 +0200 | |
branch | stable |
changeset 6290 | f68dd9dd3af2 |
parent 6283 | c827fa795a6b |
child 6333 | e3994fcc21c3 |
child 6335 | d13d488a453e |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
18 |
"""This module (``cubicweb.web.uicfg``) regroups a set of structures that may be |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
19 |
used to configure various options of the generated web interface. |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
20 |
|
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
21 |
To configure the interface generation, we use ``RelationTag`` objects. |
1739 | 22 |
|
23 |
Index view configuration |
|
24 |
```````````````````````` |
|
25 |
:indexview_etype_section: |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
26 |
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
|
27 |
|
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
28 |
* ``application`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
29 |
* ``system`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
30 |
* ``schema`` |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
31 |
* ``subobject`` (not displayed by default) |
1739 | 32 |
|
33 |
||
34 |
Actions box configuration |
|
35 |
````````````````````````` |
|
36 |
:actionbox_appearsin_addmenu: |
|
37 |
simple boolean relation tags used to control the "add entity" submenu. |
|
38 |
Relations whose rtag is True will appears, other won't. |
|
39 |
||
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
40 |
.. sourcecode:: python |
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
41 |
|
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
42 |
# Adds all subjects of the entry_of relation in the add menu of the ``Blog`` |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5314
diff
changeset
|
43 |
# primary view |
4931
92c9d0a5dc11
improve documentation for uicfg and rtags
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
4782
diff
changeset
|
44 |
uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True) |
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
|
45 |
""" |
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
|
46 |
__docformat__ = "restructuredtext en" |
1533 | 47 |
|
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
|
48 |
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
|
49 |
|
4521
32402dd2504d
missing import for 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4397
diff
changeset
|
50 |
from logilab.common.compat import any |
32402dd2504d
missing import for 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4397
diff
changeset
|
51 |
|
3057
f4ba5a251ab7
generic rtag cleaing method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
52 |
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
|
53 |
from cubicweb.rtags import (RelationTags, RelationTagsBool, RelationTagsSet, |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
54 |
RelationTagsDict, NoTargetRelationTagsDict, |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
55 |
register_rtag, _ensure_str_key) |
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
|
56 |
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
|
57 |
|
1745
7e7f04d19a98
a bunch of NameError (!) // needs review //
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1742
diff
changeset
|
58 |
|
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
59 |
# primary view configuration ################################################## |
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
60 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
61 |
def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
62 |
if rtag.get(sschema, rschema, oschema, role) is None: |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
63 |
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
|
64 |
if rschema.final: |
2671
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
65 |
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
|
66 |
or oschema.type in ('Password', 'Bytes'): |
1739 | 67 |
section = 'hidden' |
68 |
else: |
|
69 |
section = 'attributes' |
|
70 |
else: |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
71 |
if rdef.role_cardinality(role) in '1+': |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
72 |
section = 'attributes' |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
73 |
elif rdef.composite == neg_role(role): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
74 |
section = 'relations' |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
75 |
else: |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
76 |
section = 'sideboxes' |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
77 |
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
|
78 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
79 |
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
|
80 |
init_primaryview_section, |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
81 |
frozenset(('attributes', 'relations', |
5524
2f3d4ca6f7f8
[uicfg] fix handling of 'order' in the primaryview_display_ctrl rtag: consider by default only schema order, not order of appearance of rules
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
82 |
'sideboxes', 'hidden'))) |
1739 | 83 |
|
84 |
||
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
85 |
class DisplayCtrlRelationTags(NoTargetRelationTagsDict): |
1739 | 86 |
def __init__(self, *args, **kwargs): |
87 |
super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs) |
|
5524
2f3d4ca6f7f8
[uicfg] fix handling of 'order' in the primaryview_display_ctrl rtag: consider by default only schema order, not order of appearance of rules
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
88 |
self.counter = 0 |
1739 | 89 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
90 |
def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role): |
1739 | 91 |
if role == 'subject': |
92 |
oschema = '*' |
|
93 |
label = rschema.type |
|
94 |
else: |
|
95 |
sschema = '*' |
|
96 |
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
|
97 |
rtag.setdefault((sschema, rschema, oschema, role), 'label', label) |
5524
2f3d4ca6f7f8
[uicfg] fix handling of 'order' in the primaryview_display_ctrl rtag: consider by default only schema order, not order of appearance of rules
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
98 |
rtag.counter += 1 |
2f3d4ca6f7f8
[uicfg] fix handling of 'order' in the primaryview_display_ctrl rtag: consider by default only schema order, not order of appearance of rules
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
99 |
rtag.setdefault((sschema, rschema, oschema, role), 'order', rtag.counter) |
1739 | 100 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
101 |
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
|
102 |
init_primaryview_display_ctrl) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
103 |
|
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
|
104 |
|
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
105 |
# index view configuration #################################################### |
1739 | 106 |
# 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
|
107 |
# * 'application' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
108 |
# * 'system' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
109 |
# * 'schema' |
2951
d0b77dd27740
[wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
110 |
# * 'hidden' |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
111 |
# * 'subobject' (not displayed by default) |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
112 |
|
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
self.__defaults = dict(self) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
118 |
|
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
for eschema in schema.entities(): |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
122 |
if eschema.final: |
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
123 |
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
|
124 |
if eschema.schema_entity(): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
125 |
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
|
126 |
elif eschema.is_subobject(strict=True): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
127 |
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
|
128 |
else: |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
129 |
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
|
130 |
|
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
|
131 |
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
|
132 |
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
|
133 |
# 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
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
141 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1468
diff
changeset
|
142 |
# 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
|
143 |
|
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
|
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
|
151 |
def _card_and_comp(sschema, rschema, oschema, role): |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
152 |
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
|
153 |
if role == 'subject': |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
154 |
card = rdef.cardinality[0] |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
155 |
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
|
156 |
else: |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
157 |
card = rdef.cardinality[1] |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
|
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
|
161 |
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
|
162 |
"""autoform relations'section""" |
1739 | 163 |
|
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
|
164 |
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
|
165 |
'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
|
166 |
'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
|
167 |
'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
|
168 |
'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
|
169 |
'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
|
170 |
} |
1739 | 171 |
|
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 |
_allowed_form_types = ('main', 'inlined', 'muledit') |
3656
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
173 |
_allowed_values = {'main': ('attributes', 'inlined', 'relations', |
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
174 |
'metadata', 'hidden'), |
4698
9bd98fc7ef3d
[uicfg] section='inlined' is acceptable for inlined forms
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4607
diff
changeset
|
175 |
'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
|
176 |
'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
|
177 |
} |
1739 | 178 |
|
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
179 |
def init(self, schema, check=True): |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
180 |
super(AutoformSectionRelationTags, self).init(schema, check) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
181 |
self.apply(schema, self._initfunc_step2) |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
182 |
|
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
|
183 |
@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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
formsections = self.tag_container_cls() |
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
188 |
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
|
189 |
if not rschema.final: |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
190 |
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
|
191 |
if 'main_inlined' in negsects: |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
192 |
formsections.add('inlined_hidden') |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
193 |
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
|
194 |
self._tagdefs[key] = formsections |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
195 |
|
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
196 |
@staticmethod |
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
197 |
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
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
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
|
202 |
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
|
203 |
sectdict.setdefault('inlined', 'hidden') |
5712
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
204 |
elif role == 'subject' and rschema in sschema.meta_attributes(): |
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
205 |
# meta attribute, usually embeded by the described attribute's field |
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
206 |
# (eg RichTextField, FileField...) |
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
207 |
sectdict.setdefault('main', 'hidden') |
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
208 |
sectdict.setdefault('muledit', 'hidden') |
e136d392bd71
[form] refactor meta-attributes handling: hide them by default using uicfg.afs instead of returning None (or not, according to skip_meta_attr flag argument) in guess_field
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5524
diff
changeset
|
209 |
sectdict.setdefault('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
|
210 |
# 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
|
211 |
if not 'main' in sectdict: |
3729
e4f20b74af51
remove some warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
'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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
sectdict['main'] = 'metadata' |
1739 | 219 |
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
|
220 |
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
|
221 |
if card in '1+': |
3629 | 222 |
sectdict['main'] = 'attributes' |
223 |
if not 'muledit' in sectdict: |
|
224 |
sectdict['muledit'] = 'attributes' |
|
3729
e4f20b74af51
remove some warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
225 |
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
|
226 |
sectdict['main'] = 'attributes' |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
227 |
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
|
228 |
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
|
229 |
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
|
230 |
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
|
231 |
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
|
232 |
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
|
233 |
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
|
234 |
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
|
235 |
if not 'inlined' in sectdict: |
4364
766359c69f2f
[uicfg] fix autoform_section rtags initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4356
diff
changeset
|
236 |
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
|
237 |
# 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
|
238 |
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
|
239 |
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
|
240 |
|
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
|
241 |
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
|
242 |
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
|
243 |
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
|
244 |
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
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
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
|
249 |
warn('[3.6] add tag to autoform section by specifying form ' |
4146 | 250 |
'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
|
251 |
% (tag, formtype, section), DeprecationWarning, |
9ba2e3253a88
missing authorized value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3655
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
'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
|
256 |
','.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
|
257 |
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
|
258 |
'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
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
# 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
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
|
5842
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
270 |
def init_get(self, stype, rtype, otype, tagged): |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
271 |
key = (stype, rtype, otype, tagged) |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
272 |
rtags = {} |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
273 |
for key in self._get_keys(stype, rtype, otype, tagged): |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
274 |
tags = self._tagdefs.get(key, ()) |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
275 |
for tag in tags: |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
276 |
assert '_' in tag, (tag, tags) |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
277 |
section, value = tag.split('_', 1) |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
278 |
rtags[section] = value |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
279 |
cls = self.tag_container_cls |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
280 |
rtags = cls('_'.join([section,value]) for section,value in rtags.iteritems()) |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
281 |
return rtags |
10efd227648e
[fix] fix a uicfg bug in autoform_section
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5524
diff
changeset
|
282 |
|
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
|
283 |
|
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 |
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
|
285 |
# 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
|
286 |
return self._tagdefs.get(key, ()) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
287 |
|
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
"""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
|
291 |
given entity matching categories and permission. |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
292 |
|
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
|
293 |
`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
|
294 |
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
|
295 |
""" |
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
|
296 |
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
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
eid = entity.eid |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
relpermission = 'add' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
307 |
else: |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
308 |
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
|
309 |
relpermission = permission |
4072
ead446e70c28
some api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4015
diff
changeset
|
310 |
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
|
311 |
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
|
312 |
_targetschemas = [] |
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
313 |
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
|
314 |
# 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
|
315 |
# checking permission which may imply rql queries |
4007
91d11fda4aa0
more api renaming/fixing update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
4003
diff
changeset
|
316 |
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
|
317 |
continue |
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
327 |
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
|
328 |
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
|
329 |
continue |
4003
b9436fe77c9e
fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
330 |
_targetschemas.append(tschema) |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
331 |
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
|
332 |
continue |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
# 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
|
336 |
# 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
|
337 |
# created... |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
338 |
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
|
339 |
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
|
340 |
continue |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
341 |
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
|
342 |
# 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
|
343 |
# 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
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
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
|
349 |
continue |
4570
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4565
diff
changeset
|
350 |
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
|
351 |
# 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
|
352 |
# 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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
yield (rschema, targetschemas, role) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
360 |
|
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
|
361 |
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
|
362 |
|
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
|
363 |
# 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
|
364 |
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
|
365 |
|
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1747
diff
changeset
|
366 |
# relations'field explicit kwargs (given to field's __init__) |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
367 |
autoform_field_kwargs = RelationTagsDict('autoform_field_kwargs') |
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
|
368 |
|
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
|
369 |
|
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
|
370 |
# 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
|
371 |
# 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
|
372 |
# 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
|
373 |
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
|
374 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
375 |
class ReleditTags(NoTargetRelationTagsDict): |
6282
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
376 |
"""Associate to relation a dictionnary to control `reledit` (e.g. edition of |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
377 |
attributes / relations from within views). |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
378 |
|
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
379 |
Possible keys and associated values are: |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
380 |
|
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
381 |
* `novalue_label`, alternative default value (shown when there is no value). |
6282
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
382 |
|
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
383 |
* `novalue_include_rtype`, when `novalue_label` is not specified, this boolean |
6282
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
384 |
flag control wether the generated default value should contains the |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
385 |
relation label or not. Will be the opposite of the `showlabel` value found |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
386 |
in the `primaryview_display_ctrl` rtag by default. |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
387 |
|
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
388 |
* `reload`, boolean, eid (to reload to) or function taking subject and |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
389 |
returning bool/eid. This is useful when editing a relation (or attribute) |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
390 |
that impacts the url or another parts of the current displayed |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
391 |
page. Defaults to False. |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
392 |
|
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
393 |
* `rvid`, alternative view id (as str) for relation or composite edition. |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
394 |
Default is 'autolimited'. |
6282
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
395 |
|
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
396 |
* `edit_target`, may be either 'rtype' (to edit the relation) or 'related' |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
397 |
(to edit the related entity). This controls whether to edit the relation |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
398 |
or the target entity of the relation. Currently only one-to-one relations |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
399 |
support target entity edition. By default, the 'related' option is taken |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
400 |
whenever the relation is composite. |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
401 |
""" |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
402 |
_keys = frozenset('novalue_label novalue_include_rtype reload rvid edit_target'.split()) |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5849
diff
changeset
|
403 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5849
diff
changeset
|
404 |
def tag_relation(self, key, tag): |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5849
diff
changeset
|
405 |
for tagkey in tag.iterkeys(): |
6172
9987f5525e20
[web/uicfg] better error reporting for reledit_ctrl
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
406 |
assert tagkey in self._keys, 'tag %r not in accepted tags: %r' % (tag, self._keys) |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
407 |
return super(ReleditTags, self).tag_relation(key, tag) |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5849
diff
changeset
|
408 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
409 |
def init_reledit_ctrl(rtag, sschema, rschema, oschema, role): |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
410 |
if rschema.final: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
411 |
return |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
412 |
composite = rschema.rdef(sschema, oschema).composite == role |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
413 |
if role == 'subject': |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
414 |
oschema = '*' |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
415 |
else: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
416 |
sschema = '*' |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
417 |
values = rtag.get(sschema, rschema, oschema, role) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
418 |
edittarget = values.get('edit_target') |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
419 |
if edittarget not in (None, 'rtype', 'related'): |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
420 |
rtag.warning('reledit: wrong value for edit_target on relation %s: %s', |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
421 |
rschema, edittarget) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
422 |
edittarget = None |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
423 |
if not edittarget: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
424 |
edittarget = 'related' if composite else 'rtype' |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
425 |
rtag.tag_relation((sschema, rschema, oschema, role), |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
426 |
{'edit_target': edittarget}) |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
427 |
if not 'novalue_include_rtype' in values: |
6282
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
428 |
showlabel = primaryview_display_ctrl.get( |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
429 |
sschema, rschema, oschema, role).get('showlabel', True) |
556b1b1a2c5a
[reledit] new rtag entry to control apparition of relation label in default value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
430 |
rtag.tag_relation((sschema, rschema, oschema, role), |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6282
diff
changeset
|
431 |
{'novalue_include_rtype': not showlabel}) |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
432 |
|
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6172
diff
changeset
|
433 |
reledit_ctrl = ReleditTags('reledit', init_reledit_ctrl) |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5849
diff
changeset
|
434 |
|
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
|
435 |
# 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
|
436 |
|
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
|
437 |
# '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
|
438 |
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
|
439 |
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
|
440 |
if rschema in META_RTYPES: |
370d20fec445
smarter default for actionbox_appearsin_addmenu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3476
diff
changeset
|
441 |
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
|
442 |
return |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
443 |
rdef = rschema.rdef(sschema, oschema) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
444 |
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
|
445 |
rtag.tag_relation((sschema, rschema, oschema, role), True) |
1739 | 446 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
|
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
|
450 |
|
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
|
451 |
# 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
|
452 |
|
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 |
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
|
454 |
"""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
|
455 |
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
|
456 |
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
|
457 |
'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
|
458 |
DeprecationWarning, stacklevel=3) |
4261
b45a3563c6bb
fix autoform_is_inlined bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
459 |
section = tag and 'inlined' or 'hidden' |
b45a3563c6bb
fix autoform_is_inlined bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
460 |
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
|
461 |
|
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 |
# 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
|
463 |
# 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
|
464 |
# 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
|
465 |
autoform_is_inlined = AutoformIsInlined('autoform_is_inlined') |