web/uicfg.py
author sylvain.thenault@logilab.fr
Tue, 12 May 2009 11:56:12 +0200
branchtls-sprint
changeset 1739 78b0819162a8
parent 1723 30c3a713ab61
child 1742 25a765e756c4
permissions -rw-r--r--
final rtag api
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     1
# :organization: Logilab
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     2
# :copyright: 2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     3
# :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     4
"""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
     5
various places of the generated web interface.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     6
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     7
Primary view configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     8
``````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
     9
:primaryview_section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    10
   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
    11
   * 'attributes', display in the attributes section
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    12
   * 'relations', display in the relations section (below attributes)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    13
   * 'sideboxes', display in the side boxes (beside attributes)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    14
   * 'hidden', don't display
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    15
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    16
:primaryview_display_ctrl:
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
   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
    19
   following keys:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    20
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    21
   :vid:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    22
      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
    23
      the section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    24
      * 'attributes' section: 'reledit' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    25
      * 'relations' section: 'autolimited' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    26
      * 'sideboxes' section: 'sidebox' view
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    27
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    28
   :label:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    29
     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
    30
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    31
   :limit:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    32
      boolean telling if the results should be limited according to the
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    33
      configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    34
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    35
   :filter:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    36
      callback taking the related result set as argument and returning it
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    37
      filtered
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    38
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    39
   :order:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    40
      int used to control order within a section. When not specified,
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    41
      automatically set according to order in which tags are added.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    42
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    43
   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
    44
   section (controlled by :attr:`primaryview_section`)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    45
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
    46
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    47
Index view configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    48
````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    49
:indexview_etype_section:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    50
   entity type category in the index/manage page. May be one of
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    51
   * 'application'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    52
   * 'system'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    53
   * 'schema'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    54
   * 'subobject' (not displayed by default)
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
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    57
Actions box configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    58
`````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    59
:actionbox_appearsin_addmenu:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    60
  simple boolean relation tags used to control the "add entity" submenu.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    61
  Relations whose rtag is True will appears, other won't.
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    62
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    63
Automatic form configuration
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    64
````````````````````````````
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    65
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
    66
"""
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    67
__docformat__ = "restructuredtext en"
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1498
diff changeset
    68
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    69
from cubicweb.rtags import RelationTags, RelationTagsBool, RelationTagsSet
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    70
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
    71
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    72
# primary view configuration ##################################################
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    73
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    74
def init_primaryview_section(self, sschema, rschema, oschema, role):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    75
    if self.get(sschema, rschema, oschema, role) is None:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    76
        if rschema.is_final():
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    77
            if rschema.meta or tschema.type in ('Password', 'Bytes'):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    78
                section = 'hidden'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    79
            else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    80
                section = 'attributes'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    81
        elif card in '1+':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    82
            section = 'attributes'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    83
        elif composed:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    84
            section = 'relations'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    85
        else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    86
            section = 'sideboxes'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    87
        self.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
    88
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    89
primaryview_section = RelationTags(init_primaryview_section,
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    90
                                    frozenset(('attributes', 'relations',
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    91
                                               'sideboxes', 'hidden')))
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    92
for rtype in ('eid', 'creation_date', 'modification_date',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    93
              'is', 'is_instance_of', 'identity',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    94
              'owned_by', 'created_by',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    95
              'in_state', 'wf_info_for', 'require_permission',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    96
              'from_entity', 'to_entity',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    97
              'see_also'):
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    98
    primaryview_section.tag_subject_of(('*', rtype, '*'), 'hidden')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
    99
    primaryview_section.tag_object_of(('*', rtype, '*'), 'hidden')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   100
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   101
for attr in ('name', 'meta', 'final'):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   102
    primaryview_section.tag_attribute(('CWEType', attr), 'hidden')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   103
for attr in ('name', 'meta', 'final', 'symetric', 'inlined'):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   104
    primaryview_section.tag_attribute(('CWRType', attr), 'hidden')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   105
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   106
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   107
class DisplayCtrlRelationTags(RelationTags):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   108
    def __init__(self, *args, **kwargs):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   109
        super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   110
        self._counter = 0
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   111
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   112
    def tag_relation(self, key, tag):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   113
        assert isinstance(tag, dict)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   114
        super(RDisplayRelationTags, self).tag_relation(key, tag)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   115
        self._counter += 1
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   116
        tag.setdefault('order', self._counter)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   117
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   118
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   119
def init_primaryview_display_ctrl(self, sschema, rschema, oschema, role):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   120
    if role == 'subject':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   121
        oschema = '*'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   122
        label = rschema.type
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   123
    else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   124
        sschema = '*'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   125
        label = '%s_%s' % (rschema, role)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   126
    displayinfo = self.get(sschema, rschema, oschema, role)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   127
    if displayinfo is None:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   128
        displayinfo = {}
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   129
        self.tag_relation((sschema, rschema, oschema, role), displayinfo)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   130
    displayinfo.setdefault('label', label)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   131
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   132
primaryview_display_ctrl = DisplayCtrlRelationTags(init_primaryview_display_ctrl)
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   133
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   134
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   135
# index view configuration ####################################################
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   136
# 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
   137
# * 'application'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   138
# * 'system'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   139
# * 'schema'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   140
# * 'subobject' (not displayed by default)
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   141
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   142
indexview_etype_section = {'EmailAddress': 'subobject'}
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   143
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
   144
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1468
diff changeset
   145
# 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
   146
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   147
# relations'section (eg primary/secondary/generic/metadata/generated)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   148
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   149
def init_autoform_section(self, sschema, rschema, oschema, role):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   150
    if self.get(sschema, rschema, oschema, role) is None:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   151
        if role == 'subject':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   152
            card = rschema.rproperty(sschema, oschema, 'cardinality')[0]
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   153
            composed = rschema.rproperty(sschema, oschema, 'composite') == 'object'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   154
        else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   155
            card = rschema.rproperty(sschema, oschema, 'cardinality')[1]
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   156
            composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   157
        if sschema.is_metadata(rschema):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   158
            section = 'generated'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   159
        elif card in '1+':
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   160
            if not rschema.is_final() and composed:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   161
                section = 'generated'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   162
            else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   163
                section = 'primary'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   164
        elif rschema.is_final():
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   165
            section = 'secondary'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   166
        else:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   167
            section = 'generic'
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   168
        self.tag_relation((sschema, rschema, oschema, role), section)
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   169
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   170
autoform_section = RelationTags(init_autoform_section,
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   171
                                set(('primary', 'secondary', 'generic',
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   172
                                     'metadata', 'generated')))
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   173
# use primary and not generated for eid since it has to be an hidden
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   174
autoform_section.tag_attribute(('*', 'eid'), 'primary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   175
autoform_section.tag_attribute(('*', 'description'), 'secondary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   176
autoform_section.tag_attribute(('*', 'creation_date'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   177
autoform_section.tag_attribute(('*', 'modification_date'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   178
autoform_section.tag_attribute(('*', 'has_text'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   179
autoform_section.tag_subject_of(('*', 'in_state', '*'), 'primary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   180
autoform_section.tag_subject_of(('*', 'owned_by', '*'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   181
autoform_section.tag_subject_of(('*', 'created_by', '*'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   182
autoform_section.tag_subject_of(('*', 'is', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   183
autoform_section.tag_object_of(('* ', 'is', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   184
autoform_section.tag_subject_of(('*', 'is_instance_of', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   185
autoform_section.tag_object_of(('* ', 'is_instance_of', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   186
autoform_section.tag_subject_of(('*', 'identity', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   187
autoform_section.tag_object_of(('* ', 'identity', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   188
autoform_section.tag_subject_of(('*', 'require_permission', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   189
autoform_section.tag_subject_of(('*', 'wf_info_for', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   190
autoform_section.tag_object_of(('* ', 'wf_info_for', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   191
autoform_section.tag_subject_of(('*', 'for_user', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   192
autoform_section.tag_object_of(('* ', 'for_user', '*'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   193
autoform_section.tag_subject_of(('CWPermission', 'require_group', '*'), 'primary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   194
autoform_section.tag_attribute(('EEtype', 'final'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   195
autoform_section.tag_attribute(('ERtype', 'final'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   196
autoform_section.tag_attribute(('CWUser', 'firstname'), 'secondary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   197
autoform_section.tag_attribute(('CWUser', 'surname'), 'secondary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   198
autoform_section.tag_attribute(('CWUser', 'last_login_time'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   199
autoform_section.tag_subject_of(('CWUser', 'in_group', '*'), 'primary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   200
autoform_section.tag_object_of(('*', 'owned_by', 'CWUser'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   201
autoform_section.tag_object_of(('*', 'created_by', 'CWUser'), 'generated')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   202
autoform_section.tag_object_of(('*', 'bookmarked_by', 'CWUser'), 'metadata')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   203
autoform_section.tag_attribute(('Bookmark', 'path'), 'primary')
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   204
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
   205
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
   206
# relations'field class
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   207
autoform_field = RelationTags()
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
   208
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
   209
# relations'widget class
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   210
autoform_widget = RelationTags()
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   211
autoform_widget.tag_attribute(('RQLExpression', 'expression'),
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   212
                              formwidgets.TextInput)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   213
autoform_widget.tag_attribute(('Bookmark', 'path'), formwidgets.TextInput)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   214
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   215
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
   216
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   217
# inlined view flag for non final relations: when True for an entry, the
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   218
# entity(ies) at the other end of the relation will be editable from the
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   219
# form of the edited entity
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   220
autoform_is_inlined = RelationTagsBool()
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   221
autoform_is_inlined.tag_subject_of(('*', 'use_email', '*'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   222
autoform_is_inlined.tag_subject_of(('CWRelation', 'relation_type', '*'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   223
autoform_is_inlined.tag_subject_of(('CWRelation', 'from_entity', '*'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   224
autoform_is_inlined.tag_subject_of(('CWRelation', 'to_entity', '*'), True)
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   225
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
   226
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
   227
# 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
   228
# 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
   229
# permissions checking is by-passed and supposed to be ok
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   230
autoform_permissions_overrides = RelationTagsSet()
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
   231
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
   232
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
   233
# 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
   234
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
   235
# 'link' / 'create' relation tags, used to control the "add entity" submenu
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   236
def init_actionbox_appearsin_addmenu(self, sschema, rschema, oschema, role):
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   237
    if self.get(sschema, rschema, oschema, role) is None:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   238
        card = rschema.rproperty(sschema, oschema, 'cardinality')[role == 'object']
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   239
        if not card in '?1' and \
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   240
               rschema.rproperty(sschema, oschema, 'composite') == role:
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   241
            self.tag_relation((sschema, rschema, oschema, role), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   242
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   243
actionbox_appearsin_addmenu = RelationTagsBool(init_actionbox_appearsin_addmenu)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   244
actionbox_appearsin_addmenu.tag_subject_of(('*', 'is', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   245
actionbox_appearsin_addmenu.tag_object_of(('*', 'is', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   246
actionbox_appearsin_addmenu.tag_subject_of(('*', 'is_instance_of', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   247
actionbox_appearsin_addmenu.tag_object_of(('*', 'is_instance_of', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   248
actionbox_appearsin_addmenu.tag_subject_of(('*', 'identity', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   249
actionbox_appearsin_addmenu.tag_object_of(('*', 'identity', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   250
actionbox_appearsin_addmenu.tag_subject_of(('*', 'owned_by', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   251
actionbox_appearsin_addmenu.tag_subject_of(('*', 'created_by', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   252
actionbox_appearsin_addmenu.tag_subject_of(('*', 'require_permission', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   253
actionbox_appearsin_addmenu.tag_subject_of(('*', 'wf_info_for', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   254
actionbox_appearsin_addmenu.tag_object_of(('*', 'wf_info_for', '*'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   255
actionbox_appearsin_addmenu.tag_object_of(('*', 'state_of', 'CWEType'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   256
actionbox_appearsin_addmenu.tag_object_of(('*', 'transition_of', 'CWEType'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   257
actionbox_appearsin_addmenu.tag_object_of(('*', 'relation_type', 'CWRType'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   258
actionbox_appearsin_addmenu.tag_object_of(('*', 'from_entity', 'CWEType'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   259
actionbox_appearsin_addmenu.tag_object_of(('*', 'to_entity', 'CWEType'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   260
actionbox_appearsin_addmenu.tag_object_of(('*', 'in_group', 'CWGroup'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   261
actionbox_appearsin_addmenu.tag_object_of(('*', 'owned_by', 'CWUser'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   262
actionbox_appearsin_addmenu.tag_object_of(('*', 'created_by', 'CWUser'), False)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   263
actionbox_appearsin_addmenu.tag_object_of(('*', 'bookmarked_by', 'CWUser'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   264
actionbox_appearsin_addmenu.tag_subject_of(('Transition', 'destination_state', '*'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   265
actionbox_appearsin_addmenu.tag_object_of(('*', 'allowed_transition', 'Transition'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   266
actionbox_appearsin_addmenu.tag_object_of(('*', 'destination_state', 'State'), True)
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1723
diff changeset
   267
actionbox_appearsin_addmenu.tag_subject_of(('State', 'allowed_transition', '*'), True)