Commit 85e0cb0d authored by legac's avatar legac
Browse files

Remove authors and convert @type, param, rtpype, return to :type, ...

parent 18316a3e
""" Author: R. Le Gac """ The package is structured in several modules.
The most import ones are:
* *constant*
* *helper* a set of helper functions.
* *formmodifier* and *gridmodifier*, *viewportmodifier*
* *dbsvc* linking the user interface to the database
""" """
from callback import INHIBIT_DELETE_UNDEF, INHIBIT_UPDATE_UNDEF from callback import INHIBIT_DELETE_UNDEF, INHIBIT_UPDATE_UNDEF
......
""" base class to build service """ base class to build service
@author: R. Le Gac
""" """
import pprint import pprint
...@@ -16,7 +14,7 @@ class BaseSvc: ...@@ -16,7 +14,7 @@ class BaseSvc:
def dbg(self, *args): def dbg(self, *args):
"""Print C{args} if the attribute debug is true. """Print ``args`` if the attribute debug is true.
""" """
if self.debug: if self.debug:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" callback """ callback
@author: R. Le Gac
""" """
from constant import UNDEF_ID from constant import UNDEF_ID
from dbsvc import CALLBACK_ERRORS from dbsvc import CALLBACK_ERRORS
...@@ -12,11 +10,10 @@ from gluon import current ...@@ -12,11 +10,10 @@ from gluon import current
def INHIBIT_DELETE_UNDEF(set): def INHIBIT_DELETE_UNDEF(set):
"""Delete the row containing undefined value is not allowed """Delete the row containing undefined value is not allowed
@type set: gluon.dal.Set :type set: gluon.dal.Set
@param set: :param set:
@rtype: bool :returns: bool
@return:
""" """
db, T = current.globalenv['db'], current.T db, T = current.globalenv['db'], current.T
...@@ -39,11 +36,10 @@ def INHIBIT_DELETE_UNDEF(set): ...@@ -39,11 +36,10 @@ def INHIBIT_DELETE_UNDEF(set):
def INHIBIT_UPDATE_UNDEF(set, values): def INHIBIT_UPDATE_UNDEF(set, values):
"""Update the row containing undefined value is not allowed """Update the row containing undefined value is not allowed
@type set: gluon.dal.Set :type set: gluon.dal.Set
@param set: :param set:
@rtype: bool :returns: bool
@return:
""" """
db, T = current.globalenv['db'], current.T db, T = current.globalenv['db'], current.T
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" constant """ constant
@author: R. Le Gac
""" """
INLINE_ALERT = "<script>Ext.Msg.alert('%s', '%s');</script>" INLINE_ALERT = "<script>Ext.Msg.alert('%s', '%s');</script>"
UNDEF = 'undefined' UNDEF = 'undefined'
......
""" a series of converter to transform L{gluon.dal} objects into Ext JS widgets. """ a series of converter to transform L{gluon.dal} objects into Ext JS widgets.
@author: R. Le Gac
""" """
import gluon.dal import gluon.dal
import re import re
...@@ -54,25 +52,25 @@ def _to_field(field, linkedcombo=True, **kwargs): ...@@ -54,25 +52,25 @@ def _to_field(field, linkedcombo=True, **kwargs):
The conversion takes into account the L{FieldsModifier} instructions The conversion takes into account the L{FieldsModifier} instructions
but does not handle C{FieldContainer}. but does not handle C{FieldContainer}.
@param field: :param field:
@type field: gluon.dal.Field :type field: gluon.dal.Field
@type linkedcombo: bool :type linkedcombo: bool
@param linkedcombo: C{LinkedComboBox} are ignored when C{False}. :param linkedcombo: C{LinkedComboBox} are ignored when C{False}.
Useful to build grid filter. Useful to build grid filter.
@keyword kwargs: any Ext JS configuration parameters of the :keyword kwargs: any Ext JS configuration parameters of the
C{Ext.form.Field} class. They are applied in the following order: C{Ext.form.Field} class. They are applied in the following order:
constructor, modifiers and keyword arguments. constructor, modifiers and keyword arguments.
@rtype: Field :returns: Field
@note: The return configurator is a L{Field}. However it can be a :note: The return configurator is a L{Field}. However it can be a
L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ...
depending on the C{type} of the database field. depending on the C{type} of the database field.
The association is defined in the dictionary L{FTYPE_TO_XTYPE}. The association is defined in the dictionary L{FTYPE_TO_XTYPE}.
@attention: It is recommended to used the more general method L{to_field} :attention: It is recommended to used the more general method L{to_field}
which also understands C{FieldContainer}. which also understands C{FieldContainer}.
""" """
...@@ -174,32 +172,32 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs): ...@@ -174,32 +172,32 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs):
The conversion handles L{FieldContainer} and takes into account The conversion handles L{FieldContainer} and takes into account
the C{FieldsModifier} instructions. the C{FieldsModifier} instructions.
@note: The return configurator is a L{Field}. However it can be a :note: The return configurator is a L{Field}. However it can be a
L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ...
depending on the C{type} of the database field. depending on the C{type} of the database field.
The association is defined in the dictionary L{FTYPE_TO_XTYPE}. The association is defined in the dictionary L{FTYPE_TO_XTYPE}.
@note: The database fields can be organized in L{FieldContainer} :note: The database fields can be organized in L{FieldContainer}
in the application model using the modifiers L{FieldsModifier}. in the application model using the modifiers L{FieldsModifier}.
@type field: gluon.dal.Field :type field: gluon.dal.Field
@param field: :param field:
@type composite: bool :type composite: bool
@param composite: C{FieldContainer} is ignored when C{False}. :param composite: C{FieldContainer} is ignored when C{False}.
Useful to build grid filter. Useful to build grid filter.
@type linkedcombo: bool :type linkedcombo: bool
@param linkedcombo: C{LinkedComboBox} are ignored when C{False}. :param linkedcombo: C{LinkedComboBox} are ignored when C{False}.
Useful to build grid filter. Useful to build grid filter.
@param kwargs: any Ext JS configuration parameter of the C{Ext.form.Field} :param kwargs: any Ext JS configuration parameter of the C{Ext.form.Field}
class. They are applied in the following order: class. They are applied in the following order:
constructor, modifiers and keyword arguments. constructor, modifiers and keyword arguments.
@rtype: Field or C{None} :retruns: Field or C{None}
@note: Return None when composite is C{True} and when :note: Return None when composite is C{True} and when
the field is consumed by a C{FieldContainer}. the field is consumed by a C{FieldContainer}.
""" """
...@@ -244,19 +242,19 @@ def to_fields(table): ...@@ -244,19 +242,19 @@ def to_fields(table):
"""Build the list L{Field} configuration for each field """Build the list L{Field} configuration for each field
of the database C{table}. of the database C{table}.
@note: The return configuration is a L{Field}. However it can be a :note: The return configuration is a L{Field}. However it can be a
L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ...
depending on the C{type} of the database field. depending on the C{type} of the database field.
The association is defined in the dictionary L{FTYPE_TO_XTYPE}. The association is defined in the dictionary L{FTYPE_TO_XTYPE}.
@note: The function handles L{FieldSet} and L{FieldContainer} :note: The function handles L{FieldSet} and L{FieldContainer}
as well as the L{FieldsModifier} instructions. as well as the L{FieldsModifier} instructions.
The C{FieldSet} and C{FieldContainer} can be defined in the application The C{FieldSet} and C{FieldContainer} can be defined in the application
model using the modifier L{FormModifier} and the L{FieldsModifier} model using the modifier L{FormModifier} and the L{FieldsModifier}
respectively. respectively.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@rtype: list :returns: list
""" """
li = [] li = []
...@@ -325,15 +323,15 @@ def to_formPanel(table, **kwargs): ...@@ -325,15 +323,15 @@ def to_formPanel(table, **kwargs):
"""Build the L{FormPanel} configuration for the database C{table}. """Build the L{FormPanel} configuration for the database C{table}.
The conversion takes into account the L{FormModifier} instructions. The conversion takes into account the L{FormModifier} instructions.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@param kwargs: any Ext JS configuration parameter of the :param kwargs: any Ext JS configuration parameter of the
C{Ext.form.Panel} class. They are C{Ext.form.Panel} class. They are
applied in the following order: constructor, modifiers applied in the following order: constructor, modifiers
and keyword arguments. and keyword arguments.
@rtype: FormPanel :returns: FormPanel
""" """
tablename = table._tablename tablename = table._tablename
...@@ -360,15 +358,15 @@ def to_gridColumn(field, **kwargs): ...@@ -360,15 +358,15 @@ def to_gridColumn(field, **kwargs):
"""Build the L{GridColumn} configuration for the database C{field}. """Build the L{GridColumn} configuration for the database C{field}.
The conversion takes into account the L{GridModifier} instructions. The conversion takes into account the L{GridModifier} instructions.
@type field: gluon.dal.Field :type field: gluon.dal.Field
@param field: :param field:
@param kwargs: any Ext JS configuration parameter of the :param kwargs: any Ext JS configuration parameter of the
C{Ext.grid.Column} class. C{Ext.grid.Column} class.
They are applied in the following order: constructor, modifiers They are applied in the following order: constructor, modifiers
and keyword arguments. and keyword arguments.
@rtype: GridColumn :returns: GridColumn
""" """
T = current.T T = current.T
...@@ -423,10 +421,10 @@ def to_gridColumnModel(table): ...@@ -423,10 +421,10 @@ def to_gridColumnModel(table):
"""Build the L{GridColumnModel} configuration for the database C{table}. """Build the L{GridColumnModel} configuration for the database C{table}.
The conversion takes into account the L{GridModifier} instructions. The conversion takes into account the L{GridModifier} instructions.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@rtype: GridColumnModel :returns: GridColumnModel
""" """
delete_columns = [] delete_columns = []
...@@ -465,19 +463,19 @@ def to_gridFilter(table, **kwargs): ...@@ -465,19 +463,19 @@ def to_gridFilter(table, **kwargs):
"""Build the L{GridFilter} configuration for the database C{table}. """Build the L{GridFilter} configuration for the database C{table}.
The GridFilter is parametrized using the L{GridModifier}. The GridFilter is parametrized using the L{GridModifier}.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@keyword kwargs: any of the Ext JS configuration parameters of the :keyword kwargs: any of the Ext JS configuration parameters of the
C{App.grid.Filter} class. They are applied in the following order: C{App.grid.Filter} class. They are applied in the following order:
constructor, modifiers, keyword arguments. constructor, modifiers, keyword arguments.
@rtype: GridFilter :returns: GridFilter
@note: Return an empty dictionary if the GridFilter is :note: Return an empty dictionary if the GridFilter is
not defined in the application model. not defined in the application model.
@note: A filter rule is defined in the model via the L{GridModifier}. :note: A filter rule is defined in the model via the L{GridModifier}.
The rule is a C{tuple} containing 3 strings The rule is a C{tuple} containing 3 strings
C{("field1", "operator", "comment")} C{("field1", "operator", "comment")}
where C{field1} is the name of a field belonging to the C{table}. where C{field1} is the name of a field belonging to the C{table}.
...@@ -485,7 +483,7 @@ def to_gridFilter(table, **kwargs): ...@@ -485,7 +483,7 @@ def to_gridFilter(table, **kwargs):
the syntax is C{("table2.field1", "operator", "comments")}. the syntax is C{("table2.field1", "operator", "comments")}.
Valid operators are defined in the method L{dbsvc.DbSvc._encode_query}. Valid operators are defined in the method L{dbsvc.DbSvc._encode_query}.
@note: Rules are store in the modifier section C{grid_filters}. :note: Rules are store in the modifier section C{grid_filters}.
""" """
T = current.T T = current.T
...@@ -580,14 +578,14 @@ def to_gridPanel(table, **kwargs): ...@@ -580,14 +578,14 @@ def to_gridPanel(table, **kwargs):
"""Build the L{App.grid.Panel} configuration for the database C{table}. """Build the L{App.grid.Panel} configuration for the database C{table}.
The conversion takes into account the L{GridModifier} instructions. The conversion takes into account the L{GridModifier} instructions.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@keyword kwargs: any of the Ext JS configuration parameters of the :keyword kwargs: any of the Ext JS configuration parameters of the
C{App.grid.Panel} class. They are applied in the following order: C{App.grid.Panel} class. They are applied in the following order:
constructor, modifiers, keyword arguments. constructor, modifiers, keyword arguments.
@rtype: GridPanel :returns: GridPanel
""" """
tablename = table._tablename tablename = table._tablename
...@@ -624,14 +622,14 @@ def to_jsonstore(table, **kwargs): ...@@ -624,14 +622,14 @@ def to_jsonstore(table, **kwargs):
"""Build the L{DirectStore} configuration for the database C{table}. """Build the L{DirectStore} configuration for the database C{table}.
The conversion takes into account the L{StoreModifier} instructions. The conversion takes into account the L{StoreModifier} instructions.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@keyword kwargs: any of the Ext JS configuration parameters of the :keyword kwargs: any of the Ext JS configuration parameters of the
C{App.data.DirectStore} class. They are applied in the following order: C{App.data.DirectStore} class. They are applied in the following order:
constructor, modifiers, keyword arguments. constructor, modifiers, keyword arguments.
@rtype: DirectStore :returns: DirectStore
""" """
db = table._db db = table._db
...@@ -711,10 +709,10 @@ def to_jsonstore(table, **kwargs): ...@@ -711,10 +709,10 @@ def to_jsonstore(table, **kwargs):
def to_model(table): def to_model(table):
"""Build the L{Ext.data.Model} configuration for the database C{table}. """Build the L{Ext.data.Model} configuration for the database C{table}.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@rtype: dict :returns: dict
""" """
db = table._db db = table._db
...@@ -759,24 +757,24 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs): ...@@ -759,24 +757,24 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs):
"""Build the L{PanelWithUrlSelector} configuration """Build the L{PanelWithUrlSelector} configuration
where the selector is a form derived from the database C{table}. where the selector is a form derived from the database C{table}.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@type selectorTitle: str :type selectorTitle: str
@param selectorTitle: the title of the FieldSet encapsulating :param selectorTitle: the title of the FieldSet encapsulating
the selector fields. the selector fields.
@keyword baseUrl: The selected values are send to a controller :keyword baseUrl: The selected values are send to a controller
defined by the baseUrl. defined by the baseUrl.
Values are processed and results will be published in the panel. Values are processed and results will be published in the panel.
It is mandatory to specified the baseUrl. It is mandatory to specified the baseUrl.
@keyword kwargs: any of the Ext JS configuration parameters of the :keyword kwargs: any of the Ext JS configuration parameters of the
C{App.panel.WithUrlSelector} class. C{App.panel.WithUrlSelector} class.
@rtype: PanelWithUrlSelector :returns: PanelWithUrlSelector
@raise BaseException: when baseUrl is not defined. :raise BaseException: when baseUrl is not defined.
""" """
if 'baseUrl' not in kwargs: if 'baseUrl' not in kwargs:
...@@ -802,7 +800,7 @@ def to_treeNodes(): ...@@ -802,7 +800,7 @@ def to_treeNodes():
The Node structure is defined in the application model using The Node structure is defined in the application model using
L{ViewportModifier}. L{ViewportModifier}.
@rtype: list :rtype: list
""" """
cfg = [] cfg = []
...@@ -821,10 +819,10 @@ def to_viewport(**kwargs): ...@@ -821,10 +819,10 @@ def to_viewport(**kwargs):
"""Build the C{Ext.Viewport} configuration. """Build the C{Ext.Viewport} configuration.
The conversion takes into account the L{ViewportModifier} instructions. The conversion takes into account the L{ViewportModifier} instructions.
@keyword kwargs: any of the Ext JS configuration parameters of the :keyword kwargs: any of the Ext JS configuration parameters of the
C{App.viewport.Viewport} class. C{App.viewport.Viewport} class.
@rtype: dict :returns: dict
""" """
cfg = {} cfg = {}
......
""" the database service. """ the database service.
@author: R. Le Gac
""" """
import re import re
...@@ -112,8 +110,8 @@ class DbSvc(BaseSvc): ...@@ -112,8 +110,8 @@ class DbSvc(BaseSvc):
"""Check that the transaction data dictionary C{arg} """Check that the transaction data dictionary C{arg}
contains the C{keywords}. contains the C{keywords}.
@type arg: dict :type arg: dict
@param arg: transaction data :param arg: transaction data
- C{tableName} - C{tableName}
the name of the table in the database the name of the table in the database
...@@ -143,10 +141,10 @@ class DbSvc(BaseSvc): ...@@ -143,10 +141,10 @@ class DbSvc(BaseSvc):
records to be deleted. records to be deleted.
@type keywords: dict :type keywords: dict
@param keywords: list of keys which have to be in C{arg} :param keywords: list of keys which have to be in C{arg}
@raise DbSvcException: when a keyword is missing or when the table :raise DbSvcException: when a keyword is missing or when the table
does not exist in the database. does not exist in the database.
""" """
...@@ -162,8 +160,8 @@ class DbSvc(BaseSvc): ...@@ -162,8 +160,8 @@ class DbSvc(BaseSvc):
def _encode_query(self, li): def _encode_query(self, li):
"""Encode the query send by the client to a web2py C{Query}. """Encode the query send by the client to a web2py C{Query}.
@type li: list :type li: list
@param li: the query send by the client as a list of string. :param li: the query send by the client as a list of string.
The following string are understood by the method:: The following string are understood by the method::
"[table1.field1] == [table2.field2]" or "[table1, field1] == [table2, field2]" "[table1.field1] == [table2.field2]" or "[table1, field1] == [table2, field2]"
...@@ -175,17 +173,17 @@ class DbSvc(BaseSvc): ...@@ -175,17 +173,17 @@ class DbSvc(BaseSvc):
"[table1.field1] belongs (1, 2, 3)" "[table1.field1] belongs (1, 2, 3)"
"([table1.field1] == [table2.field2]) | ([table1.field2] == [table2.field1])" "([table1.field1] == [table2.field2]) | ([table1.field2] == [table2.field1])"
@rtype: tuple of gluon.dal.Query :rtype: tuple of gluon.dal.Query
@return: :return:
- the first element is the full query with all conditions or an empty string. - the first element is the full query with all conditions or an empty string.
- the second element contains only the left join conditions or an empty string. - the second element contains only the left join conditions or an empty string.
- the third element contains only the filter conditions or an empty string. - the third element contains only the filter conditions or an empty string.
@note: All elements of the list are ANDED in the web2py query :note: All elements of the list are ANDED in the web2py query
@note: comparison operators are C{==, !=, <, >, <=, >=} :note: comparison operators are C{==, !=, <, >, <=, >=}
@note: Boolean operators are C{&, |} :note: Boolean operators are C{&, |}
""" """
query, join, filter = "", "", "" query, join, filter = "", "", ""
...@@ -230,14 +228,14 @@ class DbSvc(BaseSvc): ...@@ -230,14 +228,14 @@ class DbSvc(BaseSvc):
def _get_record(self, table, id): def _get_record(self, table, id):
"""Get the record C{id} located in the database C{table}. """Get the record C{id} located in the database C{table}.
@type table: gluon.dal.Table :type table: gluon.dal.Table
@param table: :param table:
@type id: int :type id: int
@param id: :param id: