web/uicfg.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Sat, 26 Sep 2009 11:42:50 +0200
changeset 3490 1acc89d4a512
parent 3480 370d20fec445
child 3503 06bced8edddf
permissions -rw-r--r--
missing section
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     1
"""This module regroups a set of structures that may be used to configure
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     2
various places of the generated web interface.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     3
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     4
Primary view configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     5
``````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     6
:primaryview_section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     7
   where to display a relation in primary view. Value may be one of:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     8
   * 'attributes', display in the attributes section
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     9
   * 'relations', display in the relations section (below attributes)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    10
   * 'sideboxes', display in the side boxes (beside attributes)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    11
   * 'hidden', don't display
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    12
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    13
:primaryview_display_ctrl:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    14
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    15
   how to display a relation in primary view. Values are dict with some of the
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    16
   following keys:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    17
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    18
   :vid:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    19
      identifier of a view to use to display the result set. Defaults depends on
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    20
      the section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    21
      * 'attributes' section: 'reledit' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    22
      * 'relations' section: 'autolimited' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    23
      * 'sideboxes' section: 'sidebox' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    24
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    25
   :label:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    26
     label for the relations section or side box
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    27
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    28
   :limit:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    29
      boolean telling if the results should be limited according to the
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    30
      configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    31
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    32
   :filter:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    33
      callback taking the related result set as argument and returning it
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    34
      filtered
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    35
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    36
   :order:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    37
      int used to control order within a section. When not specified,
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    38
      automatically set according to order in which tags are added.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    39
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    40
   Notice those values are only considered if the relation is in a displayed
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    41
   section (controlled by :attr:`primaryview_section`)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    42
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    43
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    44
Index view configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    45
````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    46
:indexview_etype_section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    47
   entity type category in the index/manage page. May be one of
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    48
   * 'application'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    49
   * 'system'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    50
   * 'schema'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    51
   * 'subobject' (not displayed by default)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    52
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    53
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    54
Actions box configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    55
`````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    56
:actionbox_appearsin_addmenu:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    57
  simple boolean relation tags used to control the "add entity" submenu.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    58
  Relations whose rtag is True will appears, other won't.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    59
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
    60
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    61
Automatic form configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    62
````````````````````````````
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
    63
:autoform_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
    64
   where to display a relation in entity form, according to 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
    65
   `tag_attribute`, `tag_subject_of` and `tag_object_of` methods for this
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
    66
   relation tags expect two arguments additionaly to the relation key: a
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
    67
   `formtype` and a `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
    68
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
    69
   formtype may be one of:
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
    70
   * 'main', the main entity form
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
    71
   * 'inlined', the form for an entity inlined into another's one
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
    72
   * 'muledit', the multiple entity (table) form
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
    73
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
    74
   section may be one of:
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
    75
   * 'hidden', don't display
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
    76
   * 'attributes', display in the attributes 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
    77
   * 'relations', display in the relations section, using the generic relation
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
    78
     selector combobox (available in main form only, and not for attribute
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
    79
     relation)
3490
1acc89d4a512 missing section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3480
diff changeset
    80
   * 'inlined', display target entity of the relation in an inlined form
1acc89d4a512 missing section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3480
diff changeset
    81
     (available in main form only, and not for attribute relation)
3476
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
    82
   * 'metadata', display in a special metadata form (NOT YET IMPLEMENTED,
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
    83
     subject to changes)
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
    84
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
    85
:autoform_field:
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
    86
  specify a custom field instance to use for a relation
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
    87
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
    88
:autoform_field_kwargs:
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
    89
  specify a dictionnary of arguments to give to the field constructor for a
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
    90
  relation. You usually want to use either `autoform_field` 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
    91
  `autoform_field_kwargs`, not both. The later won't have any effect if 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
    92
  former is specified for a relation.
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
    93
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
    94
: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
    95
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
    96
  provide a way to by-pass security checking for dark-corner case where it can't
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
    97
  be verified properly. XXX documents.
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
    98
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    99
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1944
diff changeset
   100
:organization: Logilab
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1944
diff changeset
   101
:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1944
diff changeset
   102
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1944
diff changeset
   103
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   104
"""
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
   105
__docformat__ = "restructuredtext en"
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1498
diff changeset
   106
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
   107
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
   108
3057
f4ba5a251ab7 generic rtag cleaing method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   109
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
   110
from cubicweb.rtags import (RelationTags, RelationTagsBool, RelationTagsSet,
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   111
                            RelationTagsDict, register_rtag, _ensure_str_key)
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   112
from cubicweb.schema import META_RTYPES
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   113
from cubicweb.web import formwidgets
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   114
1745
7e7f04d19a98 a bunch of NameError (!) // needs review //
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1742
diff changeset
   115
1746
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   116
def card_from_role(card, role):
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   117
    if role == 'subject':
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   118
        return card[0]
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   119
    assert role in ('object', 'sobject'), repr(role)
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   120
    return card[1]
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   121
1944
a1b1d4f8482c similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1878
diff changeset
   122
# primary view configuration ##################################################
a1b1d4f8482c similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1878
diff changeset
   123
1742
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1739
diff changeset
   124
def init_primaryview_section(rtag, sschema, rschema, oschema, role):
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1739
diff changeset
   125
    if rtag.get(sschema, rschema, oschema, role) is None:
1746
67a9b86fd479 oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1745
diff changeset
   126
        card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role)
1944
a1b1d4f8482c similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1878
diff changeset
   127
        composed = rschema.rproperty(sschema, oschema, 'composite') == neg_role(role)
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   128
        if rschema.is_final():
2671
ee5538bdf0ea [uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2652
diff changeset
   129
            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
   130
                    or oschema.type in ('Password', 'Bytes'):
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   131
                section = 'hidden'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   132
            else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   133
                section = 'attributes'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   134
        elif card in '1+':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   135
            section = 'attributes'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   136
        elif composed:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   137
            section = 'relations'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   138
        else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   139
            section = 'sideboxes'
1742
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1739
diff changeset
   140
        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
   141
1849
1901fa97f521 give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1819
diff changeset
   142
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
   143
                                   init_primaryview_section,
1901fa97f521 give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1819
diff changeset
   144
                                   frozenset(('attributes', 'relations',
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   145
                                               'sideboxes', 'hidden')))
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   146
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   147
2369
5a2b8ed266ca new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2191
diff changeset
   148
class DisplayCtrlRelationTags(RelationTagsDict):
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   149
    def __init__(self, *args, **kwargs):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   150
        super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   151
        self._counter = 0
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   152
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   153
    def tag_relation(self, key, tag):
2369
5a2b8ed266ca new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2191
diff changeset
   154
        tag = super(DisplayCtrlRelationTags, self).tag_relation(key, tag)
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   155
        self._counter += 1
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   156
        tag.setdefault('order', self._counter)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   157
2191
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   158
    def tag_subject_of(self, key, tag):
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   159
        subj, rtype, obj = key
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   160
        if obj != '*':
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   161
            self.warning('using explict target type in display_ctrl.tag_subject_of() '
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   162
                         'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)',
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   163
                         subj, rtype, subj, rtype, obj)
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   164
        super(DisplayCtrlRelationTags, self).tag_subject_of((subj, rtype, '*'), tag)
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   165
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   166
    def tag_object_of(self, key, tag):
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   167
        subj, rtype, obj = key
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   168
        if subj != '*':
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   169
            self.warning('using explict subject type in display_ctrl.tag_object_of() '
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   170
                         'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)',
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   171
                         rtype, obj, subj, rtype, obj)
1f0fde12e35b [rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
   172
        super(DisplayCtrlRelationTags, self).tag_object_of(('*', rtype, obj), tag)
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   173
1742
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1739
diff changeset
   174
def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role):
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   175
    if role == 'subject':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   176
        oschema = '*'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   177
        label = rschema.type
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   178
    else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   179
        sschema = '*'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   180
        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
   181
    rtag.setdefault((sschema, rschema, oschema, role), 'label', label)
5a2b8ed266ca new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2191
diff changeset
   182
    rtag.setdefault((sschema, rschema, oschema, role), 'order', rtag._counter)
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   183
1849
1901fa97f521 give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1819
diff changeset
   184
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
   185
                                                   init_primaryview_display_ctrl)
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   186
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
   187
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   188
# index view configuration ####################################################
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   189
# 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
   190
# * 'application'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   191
# * 'system'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   192
# * 'schema'
2951
d0b77dd27740 [wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   193
# * 'hidden'
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   194
# * 'subobject' (not displayed by default)
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   195
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
   196
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
   197
    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
   198
        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
   199
        register_rtag(self)
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   200
2806
9d7173656a1a proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2803
diff changeset
   201
    def init(self, schema, check=True):
2803
870fa705dfde remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   202
        for eschema in schema.entities():
870fa705dfde remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   203
            if eschema.schema_entity():
2806
9d7173656a1a proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2803
diff changeset
   204
                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
   205
            elif eschema.is_subobject(strict=True):
2806
9d7173656a1a proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2803
diff changeset
   206
                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
   207
            else:
2806
9d7173656a1a proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2803
diff changeset
   208
                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
   209
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
   210
indexview_etype_section = InitializableDict(EmailAddress='subobject',
870fa705dfde remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   211
                                            CWUser='system',
870fa705dfde remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   212
                                            CWGroup='system',
870fa705dfde remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2705
diff changeset
   213
                                            CWPermission='system',
3293
69c0ba095536 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3185 3264
diff changeset
   214
                                            CWCache='system',
2968
0e3460341023 somewhat painful backport of 3.5 branch, should mostly be ok
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2806 2951
diff changeset
   215
                                            BaseTransition='hidden',
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
   216
                                            )
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   217
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1468
diff changeset
   218
# 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
   219
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
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
   221
    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
   222
    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
   223
        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
   224
        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
   225
    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
   226
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
   227
def _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
   228
    if role == 'subject':
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
        card = rschema.rproperty(sschema, oschema, 'cardinality')[0]
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
        composed = rschema.rproperty(sschema, oschema, 'composite') == 'object'
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
    else:
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 = rschema.rproperty(sschema, oschema, 'cardinality')[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
   233
        composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject'
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
    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
   235
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
   236
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
   237
    """autoform relations'section"""
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   238
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
   239
    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
   240
        '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
   241
        '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
   242
        '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
   243
        '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
   244
        '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
   245
        }
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
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
    _allowed_form_types = ('main', 'inlined', 'muledit')
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
    _allowed_values = {'main': ('attributes', 'relations', 'metadata', '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
   249
                       'inlined': ('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
   250
                       '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
   251
                       }
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
   252
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
    @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
   254
    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
   255
        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
   256
        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
   257
            formsections = 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
   258
        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
   259
        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
   260
            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
   261
            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
   262
            sectdict.setdefault('inlined', 'hidden')
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   263
        # 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
   264
        if not 'main' 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
   265
            if not rschema.is_final() and (
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
                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
   267
                '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
   268
                                                      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
   269
                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
   270
            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
   271
                sectdict['main'] = 'metadata'
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   272
            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
   273
                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
   274
                if card in '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
   275
                    if not rschema.is_final() and 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
   276
                        # XXX why? probably because we want it unlined, though
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
   277
                        # this is not the case by default
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
   278
                        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
   279
                    else:
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
   280
                        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
   281
                        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
   282
                            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
   283
                elif rschema.is_final():
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
                    sectdict['main'] = 'attributes'
3127
920079cb4e5b should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3057
diff changeset
   285
                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
   286
                    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
   287
        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
   288
            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
   289
            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
   290
                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
   291
                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
   292
                    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
   293
        if not 'inlined' 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
   294
            sectdict['inlined'] = 'hidden'
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   295
        # 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
   296
        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
   297
            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
   298
        key = _ensure_str_key( (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
   299
        self._tagdefs[key] = 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
   300
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
   301
    def tag_relation(self, key, formtype, section=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
   302
        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
   303
            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
   304
            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
   305
                warn('[3.6] add tag to autoform section by specifying form '
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
   306
                     'type and tag. Replace %s by formtype=%s, section=%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
   307
                     % (tag, formtype, section), DeprecationWarning, stacklevel=2)
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
   308
                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
   309
        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
   310
               '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
   311
            ','.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
   312
        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
   313
               '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
   314
            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
   315
        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
   316
                                         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
   317
        # 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
   318
        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
   319
            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
   320
                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
   321
                    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
   322
        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
   323
        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
   324
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   325
    def init_get(self, *key):
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   326
        return super(AutoformSectionRelationTags, self).get(*key)
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   327
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   328
    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
   329
        # overriden to avoid recomputing done in parent classes
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   330
        return self._tagdefs[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
   331
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
    def relations_by_section(self, entity, 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
   333
                             permission=None, strict=False):
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
   334
        """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
   335
        given entity matching categories and permission.
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   336
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
   337
        `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
   338
          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
   339
        """
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   340
        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
   341
        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
   342
        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
   343
        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
   344
            eid = entity.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
   345
        else:
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   346
            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
   347
            strict = False
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   348
        for rschema, targetschemas, role in eschema.relation_definitions(True):
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
            # check category first, potentially lower cost than checking
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   350
            # permission which may imply rql queries
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
   351
            if tag is not 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
   352
                targetschemas = [tschema for tschema in targetschemas
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
   353
                                 if tag in self.etype_get(eschema, 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
   354
                                                          role, tschema)]
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
   355
            if not targetschemas:
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   356
                continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   357
            if permission is not 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
   358
                # tag allowing to hijack the permission machinery when
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
                # permission is not verifiable until the entity is actually
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
   360
                # created...
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
                if eid is None and '%s_on_new' % permission in permsoverrides.etype_get(eschema, rschema, 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
   362
                    yield (rschema, targetschemas, 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
   363
                    continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   364
                if rschema.is_final():
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   365
                    if not rschema.has_perm(entity._cw, permission, 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
   366
                        continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   367
                elif role == 'subject':
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
   368
                    if not ((not strict and rschema.has_local_role(permission)) 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
   369
                            rschema.has_perm(entity._cw, permission, fromeid=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
   370
                        continue
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
   371
                    # on relation with cardinality 1 or ?, we need delete perm as well
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
   372
                    # if the relation is already set
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
   373
                    if (permission == 'add'
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
   374
                        and rschema.cardinality(eschema, targetschemas[0], role) in '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
   375
                        and eid and entity.related(rschema.type, 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
   376
                        and not rschema.has_perm(entity._cw, 'delete', fromeid=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
   377
                                                 toeid=entity.related(rschema.type, role)[0][0])):
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
   378
                        continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   379
                elif role == 'object':
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   380
                    if not ((not strict and rschema.has_local_role(permission)) 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
   381
                            rschema.has_perm(entity._cw, permission, toeid=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
   382
                        continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   383
                    # on relation with cardinality 1 or ?, we need delete perm as well
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   384
                    # if the relation is already set
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   385
                    if (permission == 'add'
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
   386
                        and rschema.cardinality(targetschemas[0], eschema, role) in '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
   387
                        and eid and entity.related(rschema.type, 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
   388
                        and not rschema.has_perm(entity._cw, 'delete', toeid=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
   389
                                                 fromeid=entity.related(rschema.type, role)[0][0])):
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   390
                        continue
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   391
            yield (rschema, targetschemas, 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
   392
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
   393
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   394
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
   395
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
   396
# 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
   397
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
   398
1754
c9c7618a90de autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents: 1747
diff changeset
   399
# relations'field explicit kwargs (given to field's __init__)
2369
5a2b8ed266ca new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2191
diff changeset
   400
autoform_field_kwargs = RelationTagsDict()
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   401
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
   402
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
   403
# 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
   404
# 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
   405
# 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
   406
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
   407
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
   408
# 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
   409
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
   410
# '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
   411
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
   412
    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
   413
        if rschema in META_RTYPES:
370d20fec445 smarter default for actionbox_appearsin_addmenu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3476
diff changeset
   414
            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
   415
            return
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   416
        card = rschema.rproperty(sschema, oschema, 'cardinality')[role == 'object']
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   417
        if not card in '?1' and \
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   418
               rschema.rproperty(sschema, oschema, 'composite') == role:
1742
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1739
diff changeset
   419
            rtag.tag_relation((sschema, rschema, oschema, role), True)
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   420
1849
1901fa97f521 give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1819
diff changeset
   421
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
   422
                                               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
   423
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
   424
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
   425
# 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
   426
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   427
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
   428
    """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
   429
    def tag_relation(self, key, 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
   430
        warn('autoform_is_inlined rtag is deprecated, use autoform_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
   431
             'with inlined formtype and "attributes" or "hidden" 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
   432
             DeprecationWarning, stacklevel=2)
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   433
        section = tag and 'attributes' or '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
   434
        autoform_section.tag_relation(key, 'inlined', 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
   435
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3369
diff changeset
   436
# 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
   437
# 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
   438
# 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
   439
autoform_is_inlined = AutoformIsInlined('autoform_is_inlined')