Skip to content
Snippets Groups Projects
Commit a93b9fe2 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Review converter.py documentation.

parent e6b5fa83
No related branches found
No related tags found
No related merge requests found
Showing
with 179 additions and 117 deletions
plugin_dbui.converter.to_field
==============================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_field
\ No newline at end of file
plugin_dbui.converter.to_fields
===============================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_fields
\ No newline at end of file
plugin_dbui.converter.to_formPanel
==================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_formPanel
\ No newline at end of file
plugin_dbui.converter.to_gridColumn
===================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_gridColumn
\ No newline at end of file
plugin_dbui.converter.to_gridColumnModel
========================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_gridColumnModel
\ No newline at end of file
plugin_dbui.converter.to_gridFilter
===================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_gridFilter
\ No newline at end of file
plugin_dbui.converter.to_gridPanel
==================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_gridPanel
\ No newline at end of file
plugin_dbui.converter.to_jsonstore
==================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_jsonstore
\ No newline at end of file
plugin_dbui.converter.to_model
==============================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_model
\ No newline at end of file
plugin_dbui.converter.to_panelWithUrlSelector
=============================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_panelWithUrlSelector
\ No newline at end of file
plugin_dbui.converter.to_treeNodes
==================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_treeNodes
\ No newline at end of file
plugin_dbui.converter.to_viewport
=================================
.. currentmodule:: plugin_dbui.converter
.. autofunction:: to_viewport
\ No newline at end of file
...@@ -173,45 +173,40 @@ def _to_field(field, linkedcombo=True, **kwargs): ...@@ -173,45 +173,40 @@ def _to_field(field, linkedcombo=True, **kwargs):
def to_field(field, composite=True, linkedcombo=True, **kwargs): def to_field(field, composite=True, linkedcombo=True, **kwargs):
"""Build the :class:`.Field` configuration for """Build the widget configuration for the database *field*.
the database field. The conversion handles
:class:`.FieldContainer` and takes into account
the :class:`.FieldsModifier` instructions.
Note: The return configuration depends on the *type* of the database field.
The return configurator is a :class:`.Field`. It can be a :class:`.Field`, a :class:`.ComboBox`, a :class:`.FieldDate`,
However it can be a :class:`.ComboBox`, a :class:`.FieldTextArea`, ...
a :class:`.FieldDate`,
:class:`.FieldTextArea`, ... The conversion takes into account the :class:`.FieldsModifier`
depending on the ``type`` of the database field. instructions and handles :class:`.FieldContainer` widget.
The association is defined in the dictionary
:const:`FTYPE_TO_XTYPE`.
Note: Note:
The database fields can be organized in Several database fields can be merged in a single
:class:`.FieldContainer` in the application :class:`.FieldContainer` widget using
model using the modifiers the method :meth:`.FieldsModifier.merge_fields`.
:class:`.FieldsModifier`.
Args: Args:
field (gluon.dal.Field); field (gluon.dal.Field):
database field.
composite (bool): ``FieldContainer`` is ignored when ``False``. composite (bool):
Useful to build grid filter. ``FieldContainer`` is ignored when ``False``.
linkedcombo (bool): ``LinkedComboBox`` are ignored when ``False``. linkedcombo (bool):
Useful to build grid filter. ``LinkedComboBox`` are ignored when ``False``.
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any Ext JS configuration parameter of the
any Ext JS configuration parameter of the ``Ext.form.Field`` ``Ext.form.Field`` widget or derived classes. They are applied
class. They are applied in the following order: in the following order: constructor, modifiers and
constructor, modifiers and keyword arguments. keyword arguments.
Returns: Returns:
* Field * Field
* ``None`` when the argument composite is ``True`` and when * ``None`` when the argument composite is ``True`` and when
the field is consumed by a ``FieldContainer``. the field is consumed by a ``FieldContainer``.
""" """
table = field.table table = field.table
...@@ -252,27 +247,30 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs): ...@@ -252,27 +247,30 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs):
def to_fields(table): def to_fields(table):
"""Build the list :class:`.Field` configuration """Build the list of widget configurations
for each field of the database ``table``. for each field of the database *table*.
The widget associated to each database field depends on its *type*.
It can be a :class:`.Field`, a :class:`.ComboBox`, a :class:`.FieldDate`,
a :class:`.FieldTextArea`, ...,
The function handles :class:`.FieldSet` and The configuration of the widget takes into
:class:`.FieldContainer` as well as the account :class:`.FieldsModifier` instructions.
:class:`.FieldsModifier` instructions. It also handles :class:`.FieldSet` as well as :class:`.FieldContainer`
The ``FieldSet`` and ``FieldContainer`` can be defined in the widgets.
application model using the modifier
:class:`.FormModifier` and the Note:
:class:`.FieldsModifier` respectively. Several database fields can be merged in a
single :class:`.FieldContainer` widget using
the method :meth:`.FieldsModifier.merge_fields`.
Similarly, they can be grouped in a :class:`.FieldSet` widget via
the method :meth:`.FormModifier.merge_fields`.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Returns: Returns:
list: list of Field elements.
The list elements are :class:`.Field`, but
it can be a :class:`.ComboBox`,
a :class:`.FieldDate`,
a :class:`.FieldTextArea`, ...,
depending on the ``type`` of the database field.
""" """
li = [] li = []
...@@ -338,22 +336,22 @@ def to_fields(table): ...@@ -338,22 +336,22 @@ def to_fields(table):
def to_formPanel(table, **kwargs): def to_formPanel(table, **kwargs):
"""Build the :class:`.FormPanel` configuration """Build the configuration of the :class:`.FormPanel` widget
for the database ``table``. The conversion takes into account the for the database ``table``.
:class:`.FormModifier` instructions.
The conversion takes into account the :class:`.FormModifier`
instructions.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any Ext JS configuration parameter of the
any Ext JS configuration parameter of the ``Ext.form.Panel`` class. They are applied in the following
``Ext.form.Panel`` class. They are order: constructor, modifiers and keyword arguments.
applied in the following order: constructor, modifiers
and keyword arguments.
Returns: Returns:
FormPanel: FormPanel
""" """
tablename = table._tablename tablename = table._tablename
...@@ -377,22 +375,22 @@ def to_formPanel(table, **kwargs): ...@@ -377,22 +375,22 @@ def to_formPanel(table, **kwargs):
def to_gridColumn(field, **kwargs): def to_gridColumn(field, **kwargs):
"""Build the :class:`.GridColumn` configuration """Build the configuration of the :class:`.GridColumn`
for the database ``field``. The conversion takes into account the for the database ``field``.
:class:`.GridModifier` instructions.
The conversion takes into account the :class:`.GridModifier`
instructions.
Args: Args:
field (gluon.dal.Field): database field field (gluon.dal.Field): database field
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any Ext JS configuration parameter of the
any Ext JS configuration parameter of the ``Ext.grid.Column`` class. They are applied in the following
``Ext.grid.Column`` class. order: constructor, modifiers and keyword arguments.
They are applied in the following order: constructor, modifiers
and keyword arguments.
Returns: Returns:
GridColumn: GridColumn
""" """
T = current.T T = current.T
...@@ -444,15 +442,17 @@ def to_gridColumn(field, **kwargs): ...@@ -444,15 +442,17 @@ def to_gridColumn(field, **kwargs):
def to_gridColumnModel(table): def to_gridColumnModel(table):
"""Build the :class:`.GridColumnModel` configuration """Build the configuration of the :class:`.GridColumnModel`
for the database ``table``. The conversion takes into account the for the database ``table``.
:class:`.GridModifier` instructions.
The conversion takes into account the :class:`.GridModifier`
instructions.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Returns: Returns:
GridColumnModel: GridColumnModel
""" """
delete_columns = [] delete_columns = []
...@@ -488,36 +488,24 @@ def to_gridColumnModel(table): ...@@ -488,36 +488,24 @@ def to_gridColumnModel(table):
def to_gridFilter(table, **kwargs): def to_gridFilter(table, **kwargs):
"""Build the :class:`.GridFilter` configuration for """Build the configuration of the :class:`.GridFilter` widget for
the database ``table``. The ``GridFilter`` is parametrized using the the database ``table``.
:class:`.GridModifier`.
The ``GridFilter`` is defined by the
method :meth:`.GridModifier.append_filter`
and :meth:`.GridModifier.configure_filters`
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any of the Ext JS configuration parameters of the
any of the Ext JS configuration parameters of the
``App.grid.Filter`` class. They are applied in the following order: ``App.grid.Filter`` class. They are applied in the following order:
constructor, modifiers, keyword arguments. constructor, modifiers, keyword arguments.
A filter rule is defined in the model via the
:class:`.GridModifier`.
The rule is a ``tuple`` containing 3 strings
``("field1", "operator", "comment")``
where ``field1`` is the name of a field belonging to the ``table``.
A more elaborate filter rule allows to filter on any foreign field using
the syntax is ``("table2.field1", "operator", "comments")``.
Valid operators are defined in the method
:meth:`.DbSvc._encode_query`.
Rules are store in the modifier section ``grid_filters``.
Returns: Returns:
GridFilter: * GridFilter
Return an empty dictionary if the GridFilter is * Empty dictionary when filters are not defined
not defined in the application model.
""" """
T = current.T T = current.T
...@@ -609,21 +597,22 @@ def to_gridFilter(table, **kwargs): ...@@ -609,21 +597,22 @@ def to_gridFilter(table, **kwargs):
def to_gridPanel(table, **kwargs): def to_gridPanel(table, **kwargs):
"""Build the :class:`.GridPanel` configuration for """Build the configuration of the :class:`.GridPanel` widget for
the database ``table``. The conversion takes into account the the database *table*.
:class:`.GridModifier` instructions.
The conversion takes into account the :class:`.GridModifier`
instructions.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any of the Ext JS configuration parameters of the
any of the Ext JS configuration parameters of the
``App.grid.Panel`` class. They are applied in the following order: ``App.grid.Panel`` class. They are applied in the following order:
constructor, modifiers, keyword arguments. constructor, modifiers, keyword arguments.
Returns: Returns:
GridPanel: GridPanel
""" """
tablename = table._tablename tablename = table._tablename
...@@ -657,21 +646,22 @@ def to_gridPanel(table, **kwargs): ...@@ -657,21 +646,22 @@ def to_gridPanel(table, **kwargs):
def to_jsonstore(table, **kwargs): def to_jsonstore(table, **kwargs):
"""Build the :class:`.DirectStore` configuration for """Build the configuration of the :class:`.DirectStore` associated
the database ``table``. The conversion takes into account the to the database *table*.
:class:`.StoreModifier` instructions.
The conversion takes into account the :class:`.StoreModifier`
instructions.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any of the Ext JS configuration parameters of the
any of the Ext JS configuration parameters of the ``App.data.DirectStore`` class. They are applied in the
``App.data.DirectStore`` class. They are applied in the following order: following order: constructor, modifiers, keyword arguments.
constructor, modifiers, keyword arguments.
Returns: Returns:
DirectStore: DirectStore
""" """
db = table._db db = table._db
...@@ -749,14 +739,14 @@ def to_jsonstore(table, **kwargs): ...@@ -749,14 +739,14 @@ def to_jsonstore(table, **kwargs):
def to_model(table): def to_model(table):
"""Build the :class:`.Model` configuration for """Build the configuration of the :class:`.Model` associated to
the database ``table``. the database ``table``.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table
Returns: Returns:
dict: dict
""" """
db = table._db db = table._db
...@@ -798,31 +788,30 @@ def to_model(table): ...@@ -798,31 +788,30 @@ def to_model(table):
def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs): def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs):
"""Build the :class:`.PanelWithUrlSelector` configuration """Build the configuration of the :class:`.PanelWithUrlSelector` widget.
where the selector is a form derived from the database ``table``.
Args: Args:
table (gluon.dal.Table): database table table (gluon.dal.Table): database table. It is used to build the form
to select values. The form has one entry per table field.
selectorTitle (str): selectorTitle (str):
the title of the FieldSet encapsulating the title of the FieldSet encapsulating
the selector fields. the selector fields.
baseUrl (str): the selected values are send to a controller baseUrl (str): the selected values are send to a controller
defined by the baseUrl.Values are processed and results defined by the baseUrl. Values are processed and results
will be published in the panel. will be published in the panel.
It is mandatory to specified the baseUrl. It is mandatory to specified the baseUrl.
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any of the Ext JS configuration parameters of the
any of the Ext JS configuration parameters of the
``App.panel.WithUrlSelector`` class. ``App.panel.WithUrlSelector`` class.
Returns: Returns:
PanelWithUrlSelector: PanelWithUrlSelector
Raises: Raises:
BaseException: when the argument``baseUrl`` is not defined. BaseException: when the argument ``baseUrl`` is not defined.
""" """
if 'baseUrl' not in kwargs: if 'baseUrl' not in kwargs:
...@@ -845,11 +834,12 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs): ...@@ -845,11 +834,12 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs):
def to_treeNodes(): def to_treeNodes():
"""Build the list of :class:`.Node`. """Build the list of :class:`.Node`.
The Node structure is defined in the application model using
:class:`.ViewportModifier`. The nodes are displayed by the viewport widget.
The list is built via the method :meth:`.ViewportModifier.add_node`.
Returns: Returns:
list: list
""" """
cfg = [] cfg = []
...@@ -865,17 +855,17 @@ def to_treeNodes(): ...@@ -865,17 +855,17 @@ def to_treeNodes():
def to_viewport(**kwargs): def to_viewport(**kwargs):
"""Build the :class:`.Viewport` configuration. """Build the configuration of the :class:`.Viewport` widget.
The conversion takes into account the
:class:`.ViewportModifier` instructions. The conversion takes into account the :class:`.ViewportModifier`
instructions.
Keyword Args: Keyword Args:
kwargs (dict): **kwargs (dict): any of the Ext JS configuration parameters of the
any of the Ext JS configuration parameters of the
``App.viewport.Viewport`` class. ``App.viewport.Viewport`` class.
Returns: Returns:
dict: dict
""" """
cfg = {} cfg = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment