# HG changeset patch # User Aurelien Campeas # Date 1271430049 -7200 # Node ID 86e5abbebfaf51921064f665dc1188ff03770169 # Parent c4fe397379c78ab606abe34924c9ef7049a2ba61 [doc/book] refresh the autoform section with uicfg content (moved there) diff -r c4fe397379c7 -r 86e5abbebfaf doc/book/en/admin/setup.rst --- a/doc/book/en/admin/setup.rst Fri Apr 16 16:43:41 2010 +0200 +++ b/doc/book/en/admin/setup.rst Fri Apr 16 17:00:49 2010 +0200 @@ -457,6 +457,3 @@ -------------------------------- .. autodocstring:: cubicweb.cwconfig - - -.. |cubicweb| replace:: *CubicWeb* diff -r c4fe397379c7 -r 86e5abbebfaf doc/book/en/development/devweb/rtags.rst --- a/doc/book/en/development/devweb/rtags.rst Fri Apr 16 16:43:41 2010 +0200 +++ b/doc/book/en/development/devweb/rtags.rst Fri Apr 16 17:00:49 2010 +0200 @@ -7,7 +7,7 @@ ~~~~~~~~~~~~~ .. automodule:: cubicweb.rtags -.. _uicfg_module: +.. _uicfg: The ``uicfg`` module ~~~~~~~~~~~~~~~~~~~~ diff -r c4fe397379c7 -r 86e5abbebfaf doc/book/en/development/devweb/views/autoform.rst --- a/doc/book/en/development/devweb/views/autoform.rst Fri Apr 16 16:43:41 2010 +0200 +++ b/doc/book/en/development/devweb/views/autoform.rst Fri Apr 16 17:00:49 2010 +0200 @@ -1,69 +1,92 @@ -The automatic entity form (:mod:`cubicweb.web.views.autoform`) ---------------------------------------------------------------- +The automatic entity form +------------------------- + +(:mod:`cubicweb.web.views.autoform`) Tags declaration -~~~~~~~~~~~~~~~~~~~~ +```````````````` It is possible to manage attributes/relations in the simple or multiple -editing form thanks of the methods bellow :: +editing form using proper uicfg tags. + +.. sourcecode:: python uicfg.autoform_section.tag_subject_of(, tag) uicfg.autoform_section.tag_object_of(, tag) uicfg.autoform_field.tag_attribute(, tag) -Where ```` is a three elements tuple ``(Subject Entity Type, -relation_type, Object Entity Type)``. ```` is a two elements tuple -``(Entity Type, Attribut Name)``. Wildcard ``*`` could be used in place of -``Entity Type`` +The details of the uicfg syntax can be found in the :ref:`uicfg` +chapter. Possible tags are detailled below -Simple Tags -~~~~~~~~~~~~~~~~~~~~ +Automatic form configuration +```````````````````````````` + +Attributes/relations display location +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* `primary`, indicates that an attribute or a relation has to be - inserted **in the simple or multiple editing forms**. In the case of - a relation, the related entity editing form will be included in the - editing form and represented as a combobox. Each item of the - combobox is a link to an existing entity. +``uicfg.autoform_section`` specifies where to display a relation in +creation/edition entity form for a given form type. ``tag_attribute``, +``tag_subject_of`` and ``tag_object_of`` methods for this relation tag expect +two arguments additionally to the relation key: a ``formtype`` and a +``section``. + +``formtype`` may be one of: + +* ``main``, the main entity form (via the modify action) +* ``inlined``, the form for an entity inlined into another form +* ``muledit``, the table form to edit multiple entities + +section may be one of: + +* ``hidden``, don't display -* `secondary`, indicates that an attribute or a relation has to be - inserted **in the simple editing form only**. In the case of a - relation, the related entity editing form will be included in the - editing form and represented as a combobox. Each item of the combobox - is a link to an existing entity. +* ``attributes``, display in the attributes section + +* ``relations``, display in the relations section, using the generic relation + selector combobox (available in main form only, and not for attribute + relation) -* `inlineview`, includes the target entity's form in the editing form - of the current entity. It allows to create the target entity in the - same time as the current entity. +* ``inlined``, display target entity of the relation in an inlined form + (available in main form only, and not for attribute relation) + +* ``metadata``, display in a special metadata form (NOT YET IMPLEMENTED, subject + to changes) -* `generic`, indicates that a relation has to be inserted in the simple - editing form, in the generic box of relation creation. +By default, mandatory relations are displayed in the ``attributes`` section, +others in ``relations`` section. + +Change default fields +^^^^^^^^^^^^^^^^^^^^^ -* `generated`, indicates that an attribute is dynamically computed - or other, and that it should not be displayed in the editing form. +Use ``autoform_field`` to replace the default field type of an attribute. -If necessary, it is possible to overwrite the method -`relation_category(rtype, x='subject')` to dynamically compute -a relation editing category. +.. warning:: + + ``autoform_field_kwargs`` should usually be used instead of + ``autoform_field``. Do not use both methods for the same relation! -Advanced Tags -~~~~~~~~~~~~~~~~~~~~ +Customize field options +^^^^^^^^^^^^^^^^^^^^^^^ + +In order to customize field options (see :class:`cubicweb.web.formfields.Field` +for a detailed list of options), use ``autoform_field_kwargs``. This rtag takes +a relation triplet and a dictionary as arguments. -Tag can also reference a custom Field crafted with the help of -``cubicweb.web.formfields`` and ``cubicweb.web.formwidget``. In the example -bellow, the field ``path`` of ``ExecData`` entities will be done with a standard -file input dialogue :: +.. sourcecode:: python - from cubicweb.web import uicfg, formfields, formwidgets - - uicfg.autoform_field.tag_attribute(('Execdata', 'path'), - formfields.FileField(name='path', widget=formwidgets.FileInput())) + # Change the content of the combobox + # here ``ticket_done_in_choices`` is a function which returns a list of + # elements to populate the combobox + uicfg.autoform_field_kwargs.tag_subject_of(('Ticket', 'done_in', '*'), {'sort': False, + 'choices': ticket_done_in_choices}) - +Overriding permissions +^^^^^^^^^^^^^^^^^^^^^^ - - +``autoform_permissions_overrides`` provides a way to by-pass security checking +for dark-corner case where it can't be verified properly. XXX documents. diff -r c4fe397379c7 -r 86e5abbebfaf doc/book/en/development/devweb/views/wdoc.rst --- a/doc/book/en/development/devweb/views/wdoc.rst Fri Apr 16 16:43:41 2010 +0200 +++ b/doc/book/en/development/devweb/views/wdoc.rst Fri Apr 16 17:00:49 2010 +0200 @@ -1,7 +1,9 @@ .. -*- coding: utf-8 -*- -Online documentation system (:mod:`cubicweb.web.views.wdoc`) -------------------------------------------------------------- +Online documentation system +--------------------------- + +(:mod:`cubicweb.web.views.wdoc`) XXX describe the on-line documentation system diff -r c4fe397379c7 -r 86e5abbebfaf rset.py --- a/rset.py Fri Apr 16 16:43:41 2010 +0200 +++ b/rset.py Fri Apr 16 17:00:49 2010 +0200 @@ -382,7 +382,7 @@ """convenience method for query retrieving a single entity, returns a partially initialized Entity instance. - .. warning: + .. warning:: Due to the cache wrapping this function, you should NEVER give row as a named parameter (i.e. rset.get_entity(req, 0) diff -r c4fe397379c7 -r 86e5abbebfaf rtags.py --- a/rtags.py Fri Apr 16 16:43:41 2010 +0200 +++ b/rtags.py Fri Apr 16 17:00:49 2010 +0200 @@ -4,7 +4,10 @@ #:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses """ -A RelationTag object is an object which allows to link a configuration information to a relation definition. For instance, the standard primary view uses a RelationTag object (uicfg.primaryview_section) to get the section to display relations. +A RelationTag object is an object which allows to link a configuration +information to a relation definition. For instance, the standard +primary view uses a RelationTag object (uicfg.primaryview_section) to +get the section to display relations. .. sourcecode:: python diff -r c4fe397379c7 -r 86e5abbebfaf web/uicfg.py --- a/web/uicfg.py Fri Apr 16 16:43:41 2010 +0200 +++ b/web/uicfg.py Fri Apr 16 17:00:49 2010 +0200 @@ -31,77 +31,6 @@ uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True) - -Automatic form configuration -```````````````````````````` - -Attributes/relations display location -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -``uicfg.autoform_section`` specifies where to display a relation in -creation/edition entity form for a given form type. ``tag_attribute``, -``tag_subject_of`` and ``tag_object_of`` methods for this relation tag expect -two arguments additionally to the relation key: a ``formtype`` and a -``section``. - -formtype may be one of: - -* ``main``, the main entity form (via the modify action) -* ``inlined``, the form for an entity inlined into another form -* ``muledit``, the table form to edit multiple entities - -section may be one of: - -* ``hidden``, don't display - -* ``attributes``, display in the attributes section - -* ``relations``, display in the relations section, using the generic relation - selector combobox (available in main form only, and not for attribute - relation) - -* ``inlined``, display target entity of the relation in an inlined form - (available in main form only, and not for attribute relation) - -* ``metadata``, display in a special metadata form (NOT YET IMPLEMENTED, subject - to changes) - -By default, mandatory relations are displayed in the ``attributes`` section, -others in ``relations`` section. - -Change default fields -^^^^^^^^^^^^^^^^^^^^^ - -Use ``autoform_field`` to replace the default field type of an attribute. - -.. Warning: - ``autoform_field_kwargs`` should usually be used instead of - ``autoform_field``. Do not use both methods for the same relation! - - -Customize field options -^^^^^^^^^^^^^^^^^^^^^^^ - -In order to customize field options (see :class:`cubicweb.web.formfields.Field` -for a detailed list of options), use ``autoform_field_kwargs``. This rtag takes -a relation triplet and a dictionary as arguments. - -.. sourcecode:: python - - # Change the content of the combobox - # here ``ticket_done_in_choices`` is a function which returns a list of - # elements to populate the combobox - uicfg.autoform_field_kwargs.tag_subject_of(('Ticket', 'done_in', '*'), {'sort': False, - 'choices': ticket_done_in_choices}) - - - -Overriding permissions -^^^^^^^^^^^^^^^^^^^^^^ - -``autoform_permissions_overrides`` provides a way to by-pass security checking -for dark-corner case where it can't be verified properly. XXX documents. - """ __docformat__ = "restructuredtext en"