diff --git a/modules/plugin_dbui/converter.py b/modules/plugin_dbui/converter.py index bb947bfdc69675588c0bb121d6a585ccc47c4be3..13985703d15548f7faf501afdd208667466ffea9 100644 --- a/modules/plugin_dbui/converter.py +++ b/modules/plugin_dbui/converter.py @@ -48,30 +48,30 @@ X_LINKED_COMBO = ['xcomboboxmaster', 'xcomboboxslave'] def _to_field(field, linkedcombo=True, **kwargs): - """Build the L{Field} configuration associated to the database C{field}. + """Build the L{Field} configuration associated to the database ``field``. The conversion takes into account the L{FieldsModifier} instructions - but does not handle C{FieldContainer}. + but does not handle ``FieldContainer``. :param field: :type field: gluon.dal.Field :type linkedcombo: bool - :param linkedcombo: C{LinkedComboBox} are ignored when C{False}. + :param linkedcombo: ``LinkedComboBox`` are ignored when ``False``. Useful to build grid filter. :keyword kwargs: any Ext JS configuration parameters of the - C{Ext.form.Field} class. They are applied in the following order: + ``Ext.form.Field`` class. They are applied in the following order: constructor, modifiers and keyword arguments. :returns: Field :note: The return configurator is a L{Field}. However it can be a L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... - depending on the C{type} of the database field. + depending on the ``type`` of the database field. The association is defined in the dictionary L{FTYPE_TO_XTYPE}. :attention: It is recommended to used the more general method L{to_field} - which also understands C{FieldContainer}. + which also understands ``FieldContainer``. """ T = current.T @@ -170,11 +170,11 @@ def _to_field(field, linkedcombo=True, **kwargs): def to_field(field, composite=True, linkedcombo=True, **kwargs): """Build the L{Field} configuration for the database field. The conversion handles L{FieldContainer} and takes into account - the C{FieldsModifier} instructions. + the ``FieldsModifier`` instructions. :note: The return configurator is a L{Field}. However it can be a L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... - depending on the C{type} of the database field. + depending on the ``type`` of the database field. The association is defined in the dictionary L{FTYPE_TO_XTYPE}. :note: The database fields can be organized in L{FieldContainer} @@ -184,21 +184,21 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs): :param field: :type composite: bool - :param composite: C{FieldContainer} is ignored when C{False}. + :param composite: ``FieldContainer`` is ignored when ``False``. Useful to build grid filter. :type linkedcombo: bool - :param linkedcombo: C{LinkedComboBox} are ignored when C{False}. + :param linkedcombo: ``LinkedComboBox`` are ignored when ``False``. 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 ``Ext.form.Field`` class. They are applied in the following order: constructor, modifiers and keyword arguments. - :returns: Field or C{None} + :returns: Field or ``None`` - :note: Return None when composite is C{True} and when - the field is consumed by a C{FieldContainer}. + :note: Return None when composite is ``True`` and when + the field is consumed by a ``FieldContainer``. """ table = field.table @@ -240,16 +240,16 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs): def to_fields(table): """Build the list L{Field} configuration for each field - of the database C{table}. + of the database ``table``. :note: The return configuration is a L{Field}. However it can be a L{ComboBox}, a L{FieldDate}, a L{FieldTextArea}, ... - depending on the C{type} of the database field. + depending on the ``type`` of the database field. The association is defined in the dictionary L{FTYPE_TO_XTYPE}. :note: The function handles L{FieldSet} and L{FieldContainer} as well as the L{FieldsModifier} instructions. - The C{FieldSet} and C{FieldContainer} can be defined in the application + The ``FieldSet`` and ``FieldContainer`` can be defined in the application model using the modifier L{FormModifier} and the L{FieldsModifier} respectively. @@ -320,14 +320,14 @@ def to_fields(table): def to_formPanel(table, **kwargs): - """Build the L{FormPanel} configuration for the database C{table}. + """Build the L{FormPanel} configuration for the database ``table``. The conversion takes into account the L{FormModifier} instructions. :type table: gluon.dal.Table :param table: :param kwargs: any Ext JS configuration parameter of the - C{Ext.form.Panel} class. They are + ``Ext.form.Panel`` class. They are applied in the following order: constructor, modifiers and keyword arguments. @@ -355,14 +355,14 @@ def to_formPanel(table, **kwargs): def to_gridColumn(field, **kwargs): - """Build the L{GridColumn} configuration for the database C{field}. + """Build the L{GridColumn} configuration for the database ``field``. The conversion takes into account the L{GridModifier} instructions. :type field: gluon.dal.Field :param field: :param kwargs: any Ext JS configuration parameter of the - C{Ext.grid.Column} class. + ``Ext.grid.Column`` class. They are applied in the following order: constructor, modifiers and keyword arguments. @@ -418,7 +418,7 @@ def to_gridColumn(field, **kwargs): def to_gridColumnModel(table): - """Build the L{GridColumnModel} configuration for the database C{table}. + """Build the L{GridColumnModel} configuration for the database ``table``. The conversion takes into account the L{GridModifier} instructions. :type table: gluon.dal.Table @@ -460,14 +460,14 @@ def to_gridColumnModel(table): def to_gridFilter(table, **kwargs): - """Build the L{GridFilter} configuration for the database C{table}. + """Build the L{GridFilter} configuration for the database ``table``. The GridFilter is parametrized using the L{GridModifier}. :type table: gluon.dal.Table :param table: :keyword kwargs: any of the Ext JS configuration parameters of the - C{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. :returns: GridFilter @@ -476,14 +476,14 @@ def to_gridFilter(table, **kwargs): not defined in the application model. :note: A filter rule is defined in the model via the L{GridModifier}. - The rule is a C{tuple} containing 3 strings - C{("field1", "operator", "comment")} - where C{field1} is the name of a field belonging to the C{table}. + 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 C{("table2.field1", "operator", "comments")}. + the syntax is ``("table2.field1", "operator", "comments")``. 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 ``grid_filters``. """ T = current.T @@ -575,14 +575,14 @@ def to_gridFilter(table, **kwargs): 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 ``table``. The conversion takes into account the L{GridModifier} instructions. :type table: gluon.dal.Table :param table: :keyword kwargs: any of the Ext JS configuration parameters of the - C{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. :returns: GridPanel @@ -619,14 +619,14 @@ def to_gridPanel(table, **kwargs): def to_jsonstore(table, **kwargs): - """Build the L{DirectStore} configuration for the database C{table}. + """Build the L{DirectStore} configuration for the database ``table``. The conversion takes into account the L{StoreModifier} instructions. :type table: gluon.dal.Table :param table: :keyword kwargs: any of the Ext JS configuration parameters of the - C{App.data.DirectStore} class. They are applied in the following order: + ``App.data.DirectStore`` class. They are applied in the following order: constructor, modifiers, keyword arguments. :returns: DirectStore @@ -707,7 +707,7 @@ def to_jsonstore(table, **kwargs): 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 ``table``. :type table: gluon.dal.Table :param table: @@ -755,7 +755,7 @@ def to_model(table): def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs): """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 ``table``. :type table: gluon.dal.Table :param table: @@ -770,7 +770,7 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs): It is mandatory to specified the baseUrl. :keyword kwargs: any of the Ext JS configuration parameters of the - C{App.panel.WithUrlSelector} class. + ``App.panel.WithUrlSelector`` class. :returns: PanelWithUrlSelector @@ -816,11 +816,11 @@ def to_treeNodes(): def to_viewport(**kwargs): - """Build the C{Ext.Viewport} configuration. + """Build the ``Ext.Viewport`` configuration. The conversion takes into account the L{ViewportModifier} instructions. :keyword kwargs: any of the Ext JS configuration parameters of the - C{App.viewport.Viewport} class. + ``App.viewport.Viewport`` class. :returns: dict diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py index 042305a723a506024af83b9d646b49c1f327f2c1..573e8564893774be2a68d5f1b0d061bd409936c1 100644 --- a/modules/plugin_dbui/dbsvc.py +++ b/modules/plugin_dbui/dbsvc.py @@ -47,102 +47,102 @@ class DbSvc(BaseSvc): """Interface the database and the client request. It is the glue between wep2py and Ext JS library. This service is the companion of L{DirectSvc} which implements - the C{Ext.Direct} protocol on the server side. - This protocol exposes methods of the C{DbSvc} service directly + the ``Ext.Direct`` protocol on the server side. + This protocol exposes methods of the ``DbSvc`` service directly on the client-side. The main methods allow to: - - C{create} a new record in a table. + - ``create`` a new record in a table. - - C{read} the content of a a table + - ``read`` the content of a a table resolving foreign key. - - C{update} the record of a table. + - ``update`` the record of a table. - - C{destroy} the record of a table. + - ``destroy`` the record of a table. - These methods receive transaction data dictionary, C{arg}: + These methods receive transaction data dictionary, ``arg``: - - C{tableName} + - ``tableName`` the name of the table in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the table. - Include foreign keys and reference fields. - - C{records} (optional) + - ``records`` (optional) - - C{[{"Table1Field1": val1,...}]} + - ``[{"Table1Field1": val1,...}]`` - A list of dictionaries containing key, value pairs for fields to be created or updated - Includes foreign key and reference field values. - - Contains the C{id} of the record to be updated. + - Contains the ``id`` of the record to be updated. - - The keys are encoded as C{Table1Field1}. + - The keys are encoded as ``Table1Field1``. - - The C{records} can also be a list containing the C{id} of the + - The ``records`` can also be a list containing the ``id`` of the records to be deleted. Each method return a dictionary: - - C{{success: True, records:[{blabla}, ..], msg: 'blalbla'}} + - ``{success: True, records:[{blabla}, ..], msg: 'blalbla'}`` - - The keyword C{success} is always present. It is mandatory for - the C{FormPanel} widget of the Ext JS library, but not strictly + - The keyword ``success`` is always present. It is mandatory for + the ``FormPanel`` widget of the Ext JS library, but not strictly required since failure can be propagated through HTTP errors. - - In the records dictionary database field are encoded as C{TableField}. + - In the records dictionary database field are encoded as ``TableField``. - - If the action failed the C{DbSvcException} is raised. + - If the action failed the ``DbSvcException`` is raised. The exception can be catch to generate an HTTP error. """ def _check_request(self, arg, keywords=('tableName', 'records')): - """Check that the transaction data dictionary C{arg} - contains the C{keywords}. + """Check that the transaction data dictionary ``arg`` + contains the ``keywords``. :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the table in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the table. - Include foreign keys and reference fields. - - C{records} (optional) + - ``records`` (optional) - - C{[{"Table1Field1": val1,...}]} + - ``[{"Table1Field1": val1,...}]`` - A list of dictionaries containing key, value pairs for fields to be created or updated - Includes foreign key and reference field values. - - Contains the C{id} of the record to be updated. + - Contains the ``id`` of the record to be updated. - - The keys are encoded as C{Table1Field1}. + - The keys are encoded as ``Table1Field1``. - - The C{records} can also be a list containing the C{id} of the + - The ``records`` can also be a list containing the ``id`` of the records to be deleted. :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 ``arg`` :raise DbSvcException: when a keyword is missing or when the table does not exist in the database. @@ -158,7 +158,7 @@ class DbSvc(BaseSvc): 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 ``Query``. :type li: list :param li: the query send by the client as a list of string. @@ -181,9 +181,9 @@ class DbSvc(BaseSvc): :note: All elements of the list are ANDED in the web2py query - :note: comparison operators are C{==, !=, <, >, <=, >=} + :note: comparison operators are ``==, !=, <, >, <=, >=`` - :note: Boolean operators are C{&, |} + :note: Boolean operators are ``&, |`` """ query, join, filter = "", "", "" @@ -226,7 +226,7 @@ class DbSvc(BaseSvc): def _get_record(self, table, id): - """Get the record C{id} located in the database C{table}. + """Get the record ``id`` located in the database ``table``. :type table: gluon.dal.Table :param table: @@ -237,7 +237,7 @@ class DbSvc(BaseSvc): :returns: dict -- key, value pairs where each key corresponds to a field of the table. Foreign keys are resolved. - The key are encoded as C{Table1Field1}. + The key are encoded as ``Table1Field1``. """ db = current.globalenv['db'] @@ -258,7 +258,7 @@ class DbSvc(BaseSvc): def _is_field_in_table(self, table, field): - """Check that the C{field} belongs to the C{table}. + """Check that the ``field`` belongs to the ``table``. :type table: gluon.dal.Table :param table: @@ -273,7 +273,7 @@ class DbSvc(BaseSvc): def _is_fields_values_valid(self, table, fields): - """Check each C{field} value against its C{validators}. + """Check each ``field`` value against its ``validators``. :type table: gluon.dal.Table @@ -281,11 +281,11 @@ class DbSvc(BaseSvc): :type fields: dict :param fields: key, value pairs where each key corresponds - to a C{gluon.dal.Field} + to a ``gluon.dal.Field`` :returns: dict -- key, value pairs for each field with errors. - The key is encoded as C{Table1Field1} and the value is a string + The key is encoded as ``Table1Field1`` and the value is a string describing the error message. """ @@ -327,7 +327,7 @@ class DbSvc(BaseSvc): def _prepare_records(self, arg): - """Prepare the transaction data dictionary, C{arg}, for its insertion + """Prepare the transaction data dictionary, ``arg``, for its insertion in the database (create or update). The method removes fields in the record which do not belong to the @@ -339,45 +339,45 @@ class DbSvc(BaseSvc): :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the table in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the table. - Include foreign keys and reference fields. - - C{records} + - ``records`` - - C{[{"Table1Field1": val1,...}]} + - ``[{"Table1Field1": val1,...}]`` - A list of dictionaries containing key, value pairs for fields to be created or updated - Includes foreign key and reference field values. - - Contains the C{id} of the record to be updated. + - Contains the ``id`` of the record to be updated. - - The keys are encoded as C{Table1Field1}. + - The keys are encoded as ``Table1Field1``. :returns: gluon.storage.Storage - - C{Storage(errors=[], records=[])} + - ``Storage(errors=[], records=[])`` - One to one correspondence between the errors and the records lists - - C{records} is a list of dictionaries containing key value pairs + - ``records`` is a list of dictionaries containing key value pairs where the key corresponds to a database field. - The keys are encoded as C{Table1Field1}. + The keys are encoded as ``Table1Field1``. - - The C{error} is C{None} when the C{record} is validated. + - The ``error`` is ``None`` when the ``record`` is validated. Otherwise the error is a dictionary - C{{Table1Field1: "error message", ...}} + ``{Table1Field1: "error message", ...}`` """ data = Storage(errors=[], records=[]) @@ -421,53 +421,53 @@ class DbSvc(BaseSvc): def create(self, arg): - """Create new records defined by the transaction data C{arg}. + """Create new records defined by the transaction data ``arg``. Several transactions of the same type are processed together. :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the tablename in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the tablename. - Include foreign keys and reference fields. - - C{records} + - ``records`` - - C{[{"Table1Field1": val1,...}]} + - ``[{"Table1Field1": val1,...}]`` - A list of dictionaries containing key, value pairs for fields to be created. - Includes foreign key and reference field values. - - The keys are encoded as C{Table1Field1}. + - The keys are encoded as ``Table1Field1``. :returns: dict - - C{{success: True, records:[{Table1Field1: val, ... }, ... ], - msg: 'blalbla'}} + - ``{success: True, records:[{Table1Field1: val, ... }, ... ], + msg: 'blalbla'}`` - - C{records} is a list of dictionary containing the complete - key, value pairs for the C{record} created in the database. + - ``records`` is a list of dictionary containing the complete + key, value pairs for the ``record`` created in the database. - - The record keys are encoded as C{Table1Field1}. + - The record keys are encoded as ``Table1Field1``. - - C{{success: False, records:[{Table1Field1: val, ... }, ... ], - errors: 'blabla', }} + - ``{success: False, records:[{Table1Field1: val, ... }, ... ], + errors: 'blabla', }`` when at least a field value is not validated or when the transaction - is kill by the callback C{table._before_insert}. + is kill by the callback ``table._before_insert``. The full transaction is aborted. The errors contains the error message return by callback or a dictionary returns by the validator. The key is the field - identifier encoded as C{Table1Field1} while the value is + identifier encoded as ``Table1Field1`` while the value is the error message. """ @@ -517,40 +517,40 @@ class DbSvc(BaseSvc): def destroy(self, arg): - """Delete existing records defined by the transaction data C{arg}. + """Delete existing records defined by the transaction data ``arg``. Several transactions of the same type are processed together. :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the tablename in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]```` - The list of database fields of the tablename. - Include foreign keys and reference fields. - - C{records} the list of C{id} for the records - to be deleted, C{[id1, id2, ... ]}. + - ``records`` the list of ``id`` for the records + to be deleted, ``[id1, id2, ... ]``. :returns: dict - - C{{success: True, records:[{Table1Id1: id}, ...], msg: 'blalbla'}} + - ``{success: True, records:[{Table1Id1: id}, ...], msg: 'blalbla'}`` - - C{records} is a list of dictionary containing the C{id} - of the delete records: C{[{TableId:xx}, ..]}. + - ``records`` is a list of dictionary containing the ``id`` + of the delete records: ``[{TableId:xx}, ..]``. - - The record key are encoded as C{Table1Field1}. + - The record key are encoded as ``Table1Field1``. - - C{{success: False, records:[{Table1Field1: id}, ... ], - errors: 'blabla', }} + - ``{success: False, records:[{Table1Field1: id}, ... ], + errors: 'blabla', }`` when at least one record does not exist or when the delete - operation is rejected by the callback C{table._before_delete}. + operation is rejected by the callback ``table._before_delete``. The full transaction is aborted. The errors contains the error messages return by the callback. @@ -596,43 +596,43 @@ class DbSvc(BaseSvc): def read(self, arg): - """Read the content of a table as specified in the transaction data C{arg}. - The C{arg} dictionary contains the following keys: + """Read the content of a table as specified in the transaction data ``arg``. + The ``arg`` dictionary contains the following keys: :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the table in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the table. - Include foreign keys and reference fields. - - C{where} (optional) + - ``where`` (optional) - - C{['db.table1.field1 == db.table2.id', ... ]} + - ``['db.table1.field1 == db.table2.id', ... ]`` - a list of string to build the inner join when handling foreign key. - The string syntax follows the web2py convention: - C{db.table1.field1 == db.table2.id}. + ``db.table1.field1 == db.table2.id``. - An AND is performed between the different elements of the list. - - C{orderby} (optional) + - ``orderby`` (optional) - - C{[("table1", "field1", "dir"), ("table2", "field3", "dir"), ...]} + - ``[("table1", "field1", "dir"), ("table2", "field3", "dir"), ...]`` - a list of tuples to build the order directive. - - the third argument is equal to C{"ASC"} or C{"DESC"}. + - the third argument is equal to ``"ASC"`` or ``"DESC"``. The transaction data can also contains parameters useful for paging. For more detail see Ext.PagingToolbar: @@ -645,12 +645,12 @@ class DbSvc(BaseSvc): :returns: dict - - C{{success: True, records: [{TableField: value, ...}, ...]}} + - ``{success: True, records: [{TableField: value, ...}, ...]}`` - - C{records} is a list of dictionary containing the key value + - ``records`` is a list of dictionary containing the key value pairs for the record found in the database. - - the record keys are encoded as C{Table1Field1}. + - the record keys are encoded as ``Table1Field1``. """ self.dbg("Start DbSvc.read") @@ -724,55 +724,55 @@ class DbSvc(BaseSvc): def update(self, arg): - """Update records defined by the transaction data C{arg}. + """Update records defined by the transaction data ``arg``. Several transactions of the same type are processed together. :type arg: dict :param arg: transaction data - - C{tableName} + - ``tableName`` the name of the tablename in the database - - C{dbFields} + - ``dbFields`` - - C{[["table1", "field1"], ... ]} + - ``[["table1", "field1"], ... ]`` - The list of database fields of the tablename. - Include foreign keys and reference fields. - - C{records} + - ``records`` - - C{[{"Table1Field1": val1,...}]} + - ``[{"Table1Field1": val1,...}]`` - A list of dictionaries containing key, value pairs for fields to be updated - Includes foreign key and reference field values. - - Contains the C{id} of the record to be updated. + - Contains the ``id`` of the record to be updated. - - The keys are encoded as C{Table1Field1}. + - The keys are encoded as ``Table1Field1``. :returns: dict - - C{{success: True, records:[{Table1Field1: val, ... }, ... ], - msg: 'blalbla'}} + - ``{success: True, records:[{Table1Field1: val, ... }, ... ], + msg: 'blalbla'}`` - - C{records} is a list of dictionary containing the complete - key, value pairs for the C{record} updated in the database. + - ``records`` is a list of dictionary containing the complete + key, value pairs for the ``record`` updated in the database. - - The record keys are encoded as C{Table1Field1}. + - The record keys are encoded as ``Table1Field1``. - - C{{success: False, records:[{Table1Field1: val, ... }, ... ], - errors: 'blabla', }} + - ``{success: False, records:[{Table1Field1: val, ... }, ... ], + errors: 'blabla', }`` when at least a field value is not validated or when the transaction - is kill by the callback C{table._before_update}. + is kill by the callback ``table._before_update``. The full transaction is aborted. The errors contains the error message return by callback or a dictionary returns by the validator. The key is the field - identifier encoded as C{Table1Field1} while the value is + identifier encoded as ``Table1Field1`` while the value is the error message. """ diff --git a/modules/plugin_dbui/directsvc.py b/modules/plugin_dbui/directsvc.py index 272bb6a207d9e81603746363386c2c666f25048d..1034673b7acd7deb917ecf28096440439d17aaad 100644 --- a/modules/plugin_dbui/directsvc.py +++ b/modules/plugin_dbui/directsvc.py @@ -1,4 +1,4 @@ -""" implementation of the C{Ext.Direct} protocol on the server-side. +""" implementation of the ``Ext.Direct`` protocol on the server-side. """ @@ -55,14 +55,14 @@ class DirectSvc(BaseSvc): On the client-side: - the API definition can be retrieved using the - URL: C{/myapplication/plugin_dbui/call/get_api} + URL: ``/myapplication/plugin_dbui/call/get_api`` - the URL to send requests is - C{/myapplication/plugin_dbui/call} + ``/myapplication/plugin_dbui/call`` - remote functions and methods can be call in the - following way C{Dbui.myfunction(a, b, callback)} - and C{MyClass.mymethod(c, d, callback)} respectively. + following way ``Dbui.myfunction(a, b, callback)`` + and ``MyClass.mymethod(c, d, callback)`` respectively. In this implementation requests and response are JSON encoded. diff --git a/modules/plugin_dbui/extjs.py b/modules/plugin_dbui/extjs.py index 0bf5edd5d8e7b7f23665b29277f77b643aaa7537..66777d9f3138c0e7fb00ebf5cc99c67110a6cb73 100644 --- a/modules/plugin_dbui/extjs.py +++ b/modules/plugin_dbui/extjs.py @@ -15,11 +15,11 @@ class ExtJSException(BaseException): pass class Base(Storage): """Base class for Ext JS configurator. - The base class comes with two methods C{append_items} - and C{append_plugins}. They are required to append C{items} - and C{plugins}. + The base class comes with two methods ``append_items`` + and ``append_plugins``. They are required to append ``items`` + and ``plugins``. - :note: A protection is set to avoid changing the C{xtype} of the element. + :note: A protection is set to avoid changing the ``xtype`` of the element. """ xtype = None @@ -29,7 +29,7 @@ class Base(Storage): :keyword kwargs: any Ext JS configuration parameter of the target class - :raise ExtJSException: if the keyword C{xtype} + :raise ExtJSException: if the keyword ``xtype`` is in the keyword arguments. """ @@ -66,67 +66,67 @@ class Base(Storage): class ArrayStore(Base): - """Configurator for the C{Ext.data.ArrayStore}.""" + """Configurator for the ``Ext.data.ArrayStore``.""" xtype='arraystore' class CheckBox(Base): - """Configurator for C{Ext.form.field.Checkbox}.""" + """Configurator for ``Ext.form.field.Checkbox``.""" xtype = 'checkbox' class ComboBox(Base): - """Configurator for C{App.form.field.CombBox}.""" + """Configurator for ``App.form.field.CombBox``.""" xtype = 'xcombobox' class DirectStore(Base): - """Configurator for C{App.data.DirectStore}.""" + """Configurator for ``App.data.DirectStore``.""" xtype = 'xdirectstore' class Field(Base): - """Configurator for C{Ext.form.field.Field}.""" + """Configurator for ``Ext.form.field.Field``.""" xtype = 'field' class FieldAceEditor(Base): - """Configurator for the C{App.form.field.AceEditor}.""" + """Configurator for the ``App.form.field.AceEditor``.""" xtype='xaceeditorfield' class FieldContainer(Base): - """Configurator for C{Ext.form.FieldContainer}.""" + """Configurator for ``Ext.form.FieldContainer``.""" xtype = 'fieldcontainer' class FieldDate(Base): - """Configurator for C{Ext.form.field.Date}.""" + """Configurator for ``Ext.form.field.Date``.""" xtype = 'datefield' class FieldDict(Base): - """Configurator for C{App.form.field.Dict}.""" + """Configurator for ``App.form.field.Dict``.""" xtype = 'xdictfield' class FieldList(Base): - """Configurator for C{App.form.field.List}.""" + """Configurator for ``App.form.field.List``.""" xtype = 'xlistfield' class FieldNumber(Base): - """Configurator for C{Ext.form.field.Number}.""" + """Configurator for ``Ext.form.field.Number``.""" xtype = 'numberfield' class FieldSet(Base): - """Configurator for C{Ext.form.FieldSet}.""" + """Configurator for ``Ext.form.FieldSet``.""" xtype = 'fieldset' class FieldText(Base): - """Configurator for C{Ext.form.field.Text}. + """Configurator for ``Ext.form.field.Text``. :note: Regular expression for the validation can be written as a string. @@ -139,7 +139,7 @@ class FieldText(Base): class FieldTextArea(Base): - """Configurator for C{Ext.form.field.TextArea}. + """Configurator for ``Ext.form.field.TextArea``. :note: Regular expression for the validation can be written as a string. @@ -152,59 +152,59 @@ class FieldTextArea(Base): class FieldTime(Base): - """Configurator for C{Ext.form.field.Time}.""" + """Configurator for ``Ext.form.field.Time``.""" xtype = 'timefield' class FormPanel(Base): - """Configurator for C{App.form.Panel}.""" + """Configurator for ``App.form.Panel``.""" xtype = 'xform' class GridColumn(dict): - """Configurator for C{Ext.grid.Column}.""" + """Configurator for ``Ext.grid.Column``.""" class GridColumnModel(list): - """Configurator for C{Ext.grid.ColumnModel}. + """Configurator for ``Ext.grid.ColumnModel``. - :note: It is implemented as a C{list} of L{GridColumn}. + :note: It is implemented as a ``list`` of L{GridColumn}. """ class GridFilter(Base): - """Configurator for C{App.grid.Filter}.""" + """Configurator for ``App.grid.Filter``.""" xtype = 'xgridfilter' class GridPanel(Base): - """Configurator for C{App.grid.Panel}.""" + """Configurator for ``App.grid.Panel``.""" xtype = 'xgrid' class GridRowNumberer(Base): - """Configurator for C{Ext.grid.column.RowNumberer}.""" + """Configurator for ``Ext.grid.column.RowNumberer``.""" xtype = 'rownumberer' class GridTemplateColumn(Base): - """Configurator for C{Ext.grid.TemplateColumn}.""" + """Configurator for ``Ext.grid.TemplateColumn``.""" xtype = 'templatecolumn' class GridWithFilter(Base): - """Configurator for C{App.panel.GridWithFilter}.""" + """Configurator for ``App.panel.GridWithFilter``.""" xtype = 'xgridwithfilter' class JsonStore(Base): - """Configurator for the C{Ext.data.JsonStore}.""" + """Configurator for the ``Ext.data.JsonStore``.""" xtype='jsonstore' class Model(dict): - """Configurator for the C{Ext.data.Model}. """ + """Configurator for the ``Ext.data.Model``. """ def __init__(self, **kwargs): dict.__init__(self, **kwargs) @@ -212,36 +212,36 @@ class Model(dict): class Panel(Base): - """Configurator for C{Ext.panel.Panel}.""" + """Configurator for ``Ext.panel.Panel``.""" xtype = 'panel' class PanelWithUrlSelector(Base): - """Configurator for C{App.panel.WithUrlSelector}.""" + """Configurator for ``App.panel.WithUrlSelector``.""" xtype = 'xpanelwithurlselector' class Store(Base): - """Configurator for the C{Ext.data.Store}.""" + """Configurator for the ``Ext.data.Store``.""" xtype='store' class TabPanel(Base): - """Configurator for C{Ext.tab.Panel}.""" + """Configurator for ``Ext.tab.Panel``.""" xtype = 'tabpanel' class Viewport(Base): - """Configurator for C{App.viewport.Viewport}.""" + """Configurator for ``App.viewport.Viewport``.""" xtype = 'xviewport' class Window(Base): - """Configurator for C{Ext.Window}.""" + """Configurator for ``Ext.Window``.""" xtype = 'window' class XmlStore(Base): - """Configurator for the C{Ext.data.XmlStore}.""" + """Configurator for the ``Ext.data.XmlStore``.""" xtype='xmlstore' \ No newline at end of file diff --git a/modules/plugin_dbui/fieldsmodifier.py b/modules/plugin_dbui/fieldsmodifier.py index 2a8fcd172d8c0292b0ad9c7fcb5fbcf031fd2758..b65f3d3be6bcb156b318ae4f05cc447cfbadb21a 100644 --- a/modules/plugin_dbui/fieldsmodifier.py +++ b/modules/plugin_dbui/fieldsmodifier.py @@ -16,7 +16,7 @@ class FieldsModifier(Modifier): def __init__(self, tablename): """Initialize the fields modifier associated to the database - table C{tablename}. + table ``tablename``. The data structure of the fields modifier can be access outside the class: @@ -24,21 +24,21 @@ class FieldsModifier(Modifier): >>> p = PluginManager('dbui') >>> modifier = p.dbui['modifier_fields'][tablename] - or internally via the attribute C{data}. + or internally via the attribute ``data``. - The keys of the C{data} structure are: + The keys of the ``data`` structure are: - - C{extjs_fields} (dict) Ext JS configuration options - for individual C{field}. + - ``extjs_fields`` (dict) Ext JS configuration options + for individual ``field``. - - C{composite_fields.main} (list) the first field - of the C{FieldContainer}. + - ``composite_fields.main`` (list) the first field + of the ``FieldContainer``. - - C{composite_fields.others} (list of list) the others field of - the C{FieldContainer}. + - ``composite_fields.others`` (list of list) the others field of + the ``FieldContainer``. - - There is one to one correspondence between the C{composite_fields.main} - and the C{composite_fields.others} lists. + - There is one to one correspondence between the ``composite_fields.main`` + and the ``composite_fields.others`` lists. :type tablename: str :param tablename: name of the database table @@ -70,7 +70,7 @@ class FieldsModifier(Modifier): def configure_field(self, field, **kwargs): """Update the configuration options of the Ext JS widget - associated to the C{field}. + associated to the ``field``. Existing value of the configuration options are replace by those defined by the keyword arguments. @@ -83,10 +83,10 @@ class FieldsModifier(Modifier): def merge_fields(self, *fields, **kwargs): - """Merge fields in a C{FieldContainer}. + """Merge fields in a ``FieldContainer``. The default configuration is with an horizontal layout with a unique - label defined by the keyword parameter C{fieldLabel}. More precisely, + label defined by the keyword parameter ``fieldLabel``. More precisely, the following Ext JS configuration parameters are set:: combineLabels = True, @@ -96,11 +96,11 @@ class FieldsModifier(Modifier): They can be super seed by the keyword arguments. :note: - - Each C{field} is identified by its database field name. - - C{field} should belong to the database table defined in the constructor. - - The first C{field} is the main field of the C{FieldContainer}. + - Each ``field`` is identified by its database field name. + - ``field`` should belong to the database table defined in the constructor. + - The first ``field`` is the main field of the ``FieldContainer``. - The keyword arguments contains the configuration options of - the C{Ext.form.FieldContainer} widget. + the ``Ext.form.FieldContainer`` widget. """ # configuration of the FieldContainer diff --git a/modules/plugin_dbui/formmodifier.py b/modules/plugin_dbui/formmodifier.py index f6630ce5988c2e7e6715f5d9ea5e55641455a7cd..fc86b3efb2517941103c272a215b2fbd4a3b5ac8 100644 --- a/modules/plugin_dbui/formmodifier.py +++ b/modules/plugin_dbui/formmodifier.py @@ -26,7 +26,7 @@ def configure_forms(db, **extjs): associated table name. :note: The keyword arguments define values for the Ext JS configuration - options of he C{Ext.form.Panel} class. + options of he ``Ext.form.Panel`` class. """ if isinstance(db, DAL): @@ -48,7 +48,7 @@ class FormModifier(Modifier): def __init__(self, tablename): """Initialize the form modifier associated to the database - table C{tablename}. + table ``tablename``. The data structure of the form modifier can be access outside the class: @@ -56,24 +56,24 @@ class FormModifier(Modifier): >>> p = PluginManager('dbui') >>> modifier = p.dbui['modifier_forms'][tablename] - or internally via the attribute C{data}. + or internally via the attribute ``data``. - The keys of the C{data} structure are: + The keys of the ``data`` structure are: - - C{extjs} (dict) Ext JS configuration options for the form widget. + - ``extjs`` (dict) Ext JS configuration options for the form widget. - - C{field_sets} (list of Storage) each C{Storage} defined a - C{FieldSets}. It has two keys C{fields} and C{extjs}. + - ``field_sets`` (list of Storage) each ``Storage`` defined a + ``FieldSets``. It has two keys ``fields`` and ``extjs``. The former is a list of field names belonging to the table defined in the constructor. The latter is a dictionary with - the configuration options of the C{Ext.form.FieldSet} widget. + the configuration options of the ``Ext.form.FieldSet`` widget. - - C{hidden_fields} (list) list of field names to be hidden in + - ``hidden_fields`` (list) list of field names to be hidden in the form. The fields have to belong to the table defined in the constructor. - - C{mapper} (None or function) reference to the function used - to organize the C{FieldSet} in C{Tabs}, for example. + - ``mapper`` (None or function) reference to the function used + to organize the ``FieldSet`` in ``Tabs``, for example. :type tablename: str :param tablename: name of the database table @@ -112,12 +112,12 @@ class FormModifier(Modifier): :type master: gluon.dal.Field :keyword master: the field used as master. It has to be defined in the table referenced in the constructor - and in the C{masterHasSlaveData} table. + and in the ``masterHasSlaveData`` table. :type slave: gluon.dal.Field :keyword slave: the field used as salve. It has to be defined in the table referenced in the constructor - and in the C{masterHasSlaveData} table. + and in the ``masterHasSlaveData`` table. :type masterHasSlaveData: str :keyword masterHasSlaveData: name of the external database table. @@ -198,13 +198,13 @@ class FormModifier(Modifier): def merge_fields(self, *fields, **kwargs): """Merge fields in a L{FieldSet} corresponding to - an C{Ext.form.FieldSet} widget. + an ``Ext.form.FieldSet`` widget. - Each C{field} is either a string identifying the database field by its name - or an instance of the Ext JS configurator like the C{Spacer}. + Each ``field`` is either a string identifying the database field by its name + or an instance of the Ext JS configurator like the ``Spacer``. The keyword argument define values for the configuration options of - the C{Ext.form.FieldSet} widget. + the ``Ext.form.FieldSet`` widget. """ # by default the field occupies all the field set space diff --git a/modules/plugin_dbui/gridmodifier.py b/modules/plugin_dbui/gridmodifier.py index 6e89f8f99930dc1febb11633b67c02febf0b2c75..35bbf7ed8b5c8386a87a98df4e38df387700455b 100644 --- a/modules/plugin_dbui/gridmodifier.py +++ b/modules/plugin_dbui/gridmodifier.py @@ -53,7 +53,7 @@ class GridModifier(Modifier): def __init__(self, tablename): """Initialize the grid modifier associated to the database - table C{tablename}. + table ``tablename``. The data structure of the grid modifier can be access outside the class: @@ -61,25 +61,25 @@ class GridModifier(Modifier): >>> p = PluginManager('dbui') >>> modifier = p.dbui['modifier_grids'][tablename] - or internally via the attribute C{data}. + or internally via the attribute ``data``. - The keys of the C{data} structure are: + The keys of the ``data`` structure are: - - C{extjs} (dict) Ext JS configuration options for the grid widget. + - ``extjs`` (dict) Ext JS configuration options for the grid widget. - - C{configure_columns} (dict) the Ext JS configuration options for - the C{Ext.grid.Column} widget. The column is identify by its - C{fieldname}. + - ``configure_columns`` (dict) the Ext JS configuration options for + the ``Ext.grid.Column`` widget. The column is identify by its + ``fieldname``. - - C{delete_columns} (list) + - ``delete_columns`` (list) - - C{grid_filters} (storage) + - ``grid_filters`` (storage) - - C{hidden_columns} (list) + - ``hidden_columns`` (list) - - C{row_numbering} (bool) + - ``row_numbering`` (bool) - - C{template_columns} (list + - ``template_columns`` (list :type tablename: str :param tablename: name of the database table @@ -126,9 +126,9 @@ class GridModifier(Modifier): :param filter: A filter is defined by a tuple containing three strings: - The database field name. The field has to belong to the database table defined in the constructor. - However, the more elaborate syntax, C{'table2.field1'}, + However, the more elaborate syntax, ``'table2.field1'``, allows to use foreign field. - - The operator, C{'=='}, C{'contains'}, ... + - The operator, ``'=='``, ``'contains'``, ... Valid operator are defined in the method L{dbsvc.DbSvc._encode_query} - The comment for the tool tip. @@ -151,35 +151,35 @@ class GridModifier(Modifier): It has to belong to the table defined in the constructor. The keyword arguments defines the configuration options - for the associated C{Ext.grid.Column} widget. + for the associated ``Ext.grid.Column`` widget. """ self.data.configure_columns[fieldname] = kwargs def configure_filters(self, **kwargs): - """Configure the C{Ext.form.FieldSet} embedded in the GridFilter. + """Configure the ``Ext.form.FieldSet`` embedded in the GridFilter. The latter is created automatically as soon as a filter is defined. Filter are defined and tuned individually using the method L{append_filter}. The keyword argument contains Ext JS configuration options - for the C{Ext.form.FieldSet} + for the ``Ext.form.FieldSet`` """ self.data.grid_filters.extjs = kwargs def configure_gridWithFilter(self, **kwargs): - """Configure the C{App.grid.GridwithFilter} widget. + """Configure the ``App.grid.GridwithFilter`` widget. """ self.data.grid_with_filter.extjs = kwargs def delete_columns(self, *fields): - """Delete the columns in the C{Ext.grid.Panel} widget. + """Delete the columns in the ``Ext.grid.Panel`` widget. Each column is identified by its database field name. """ @@ -189,7 +189,7 @@ class GridModifier(Modifier): def hide_columns(self, *fields): - """Hide the columns in the C{Ext.grid.Panel} widget. + """Hide the columns in the ``Ext.grid.Panel`` widget. Each column is identified by its database field name. """ @@ -199,8 +199,8 @@ class GridModifier(Modifier): def merge_columns(self, *fields, **kwargs): - """Merge several fields in a single C{TemplateColumn}. - The TemplateColumn is rendered by the C{Ext.grid.TemplateColumn}. + """Merge several fields in a single ``TemplateColumn``. + The TemplateColumn is rendered by the ``Ext.grid.TemplateColumn``. Each field is identified by its database field name. :keyword header: (str) the header of the TemplateColumn @@ -208,11 +208,11 @@ class GridModifier(Modifier): :keyword tpl: (list) the template defining how fields are displayed in the TemplateColumn. - The syntax of the template is is defined in the documentation - of C{Ext.XTemplate} constructor. + of ``Ext.XTemplate`` constructor. - There is some limitation when defining the template in python, namely the use of the template member function. - - Database fields are identified using the C{CapWord} syntax: - C{TablenameFieldname}. It works for standard and reference fields. + - Database fields are identified using the ``CapWord`` syntax: + ``TablenameFieldname``. It works for standard and reference fields. - HTML balises are understood. - Example of a template list:: @@ -221,14 +221,14 @@ class GridModifier(Modifier): '<tpl if={PeoplePhone_number}>{PeoplePhone_number}</tpl>'] :keyword autohide: (bool) hide the columns associated to the fields - used in the TemplateColumn when set to C{True}. + used in the TemplateColumn when set to ``True``. :keyword position: (int) is a number defining where the column will be inserted in the grid widget. The first column is at 0. :keyword extjs: (dict) contains the Ext JS configuration options - of the C{Ext.grid.TemplateColumn}. + of the ``Ext.grid.TemplateColumn``. """ keywords = ['autohide', 'position'] @@ -261,6 +261,6 @@ class GridModifier(Modifier): By default it is activate for all grids. :type bool: boolean - :param bool: activate the row numbering when C{True}. + :param bool: activate the row numbering when ``True``. """ self.data.row_numbering = bool diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index a0d4eaf1a1eb680404180b3207e29a962183bf00..c12ade4f7e00763bcb2779b4b0eb70b880e05439 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -26,8 +26,8 @@ STOREID = '%sStore' def as_list(val): - """Encapsulated C{val} into a C{list} when C{val} is not an - instance of a C{list}. + """Encapsulated ``val`` into a ``list`` when ``val`` is not an + instance of a ``list``. :type val: any :param val: input value @@ -62,7 +62,7 @@ def decode_field(field): The reverse function is L{encode_field}. :note: useful to decode database field name: - C{"TableField"} or C{"TableFieldFunction"} + ``"TableField"`` or ``"TableFieldFunction"`` :type field: str @@ -79,8 +79,8 @@ def decode_field(field): def dummy_row(table, value=''): - """Create a dummy C{Row} for the C{table}. The row contains keys for - the table and for the reference tables. Each field are set to C{value}. + """Create a dummy ``Row`` for the ``table``. The row contains keys for + the table and for the reference tables. Each field are set to ``value``. The Row van be inserted in a gluon.dal.Rows:: @@ -122,8 +122,8 @@ def encode_field(*args): :returns: str - :note: useful to build database field name like C{TableField} - or C{TableFieldFunc}. + :note: useful to build database field name like ``TableField`` + or ``TableFieldFunc``. :note: The Ext JS ComboBox don't decode properly any separator between table and field like table+field. Therefore choice for the encoding @@ -155,7 +155,7 @@ def encode_validator_errors(error): def get_all_tables(dal): - """Get the list of names for all tables in the database, C{dal}, + """Get the list of names for all tables in the database, ``dal``, including alias table. :type dal: gluon.dal.DAL @@ -173,7 +173,7 @@ def get_all_tables(dal): def get_create_id(table, **kwargs): - """Get the C{id} of the record identified by a set of C{field=value} + """Get the ``id`` of the record identified by a set of ``field=value`` keyword arguments. If the record does not exist it is created with the values specified in the keywords arguments. @@ -184,7 +184,7 @@ def get_create_id(table, **kwargs): :type table: gluon.dal.Table - :returns: int -- the C{id} of the record. + :returns: int -- the ``id`` of the record. """ id = get_id(table, **kwargs) @@ -203,8 +203,8 @@ def get_field_validators(field): :returns: dict -- The keys depend on the validators. - Typical one are C{minValue}, C{maxValue}, C{regex}, C{regexText}, - C{maxLength}, C{minLength}, ... + Typical one are ``minValue``, ``maxValue``, ``regex``, ``regexText``, + ``maxLength``, ``minLength``, ... """ cfg = {} @@ -249,7 +249,7 @@ def get_field_validators(field): def get_file_paths(path, ext=None, alpha=True): """get the local paths for files matching the arguments. For example, to get the paths of the javascript source files - located in the local directory C{static/plugin_dbui/src}:: + located in the local directory ``static/plugin_dbui/src``:: li = get_file_paths("static/plugin_dbui/src", ext=".js") @@ -258,20 +258,20 @@ def get_file_paths(path, ext=None, alpha=True): :type path: None, list or string :param path: local path defining the target files: - - C{None}. + - ``None``. - - a C{string} pointing to one files. + - a ``string`` pointing to one files. - - a C{list} of strings pointing to several files. + - a ``list`` of strings pointing to several files. - - a C{string} pointing to a directory. + - a ``string`` pointing to a directory. - - a C{list} of string pointing to files and directory. + - a ``list`` of string pointing to files and directory. :type ext: str - :param ext: select only files with the extension C{ext}, I{i.e} - C{.js}, C{.css}, ... + :param ext: select only files with the extension ``ext``, I{i.e} + ``.js``, ``.css``, ... :type alpha: bool :param alpha: sort the paths in alphabetic order @@ -305,26 +305,26 @@ def get_file_paths(path, ext=None, alpha=True): def get_foreign_field(field): """Get a tuple with the reference table name, reference field name and - reference primary key name, for the C{field}. + reference primary key name, for the ``field``. :type field: gluon.dal.Field :returns: tuple - - C{(k_tablename, k_fieldname, k_keyname)} + - ``(k_tablename, k_fieldname, k_keyname)`` - - C{k_tablename} is the name of the reference table + - ``k_tablename`` is the name of the reference table - - C{k_fieldname} is the name of the reference field, I{i.e} - C{table.field} S{->} C{k_table.k_field} + - ``k_fieldname`` is the name of the reference field, I{i.e} + ``table.field`` S{->} ``k_table.k_field`` - - C{k_keyname} is the name of the primary key of the reference table. + - ``k_keyname`` is the name of the primary key of the reference table. It is requires by the left join, - C{table.field == k_table.k_key}. - In almost all case C{k_key} is equal to C{id}. + ``table.field == k_table.k_key``. + In almost all case ``k_key`` is equal to ``id``. - - C{None} for standard field. + - ``None`` for standard field. """ if not is_foreign_field(field): @@ -363,12 +363,12 @@ def get_foreign_field(field): def get_id(table, **kwargs): - """Get the C{id} of the record identified by a set of C{field=value} - keyword arguments. Return C{None} if the record does not exist. + """Get the ``id`` of the record identified by a set of ``field=value`` + keyword arguments. Return ``None`` if the record does not exist. :type table: gluon.dal.Table - :returns: int or None -- the C{id} of the record. + :returns: int or None -- the ``id`` of the record. """ query = None @@ -389,7 +389,7 @@ def get_id(table, **kwargs): def get_language(): """Get the primary language of the application from the HTML - language code, I{i.e} C{en}, C{fr}, .... + language code, I{i.e} ``en``, ``fr``, .... :returns: str @@ -409,14 +409,14 @@ def get_plugin_path(plugin_name): """Get the local path of the plugin identified by its name. :type plugin_name: str - :param plugin_name: name of the plugin, I{i.e} C{"plugin_dbui"}. + :param plugin_name: name of the plugin, I{i.e} ``"plugin_dbui"``. :returns: str - - the path of the first directory starting with C{plugin_name}. + - the path of the first directory starting with ``plugin_name``. - the local path is relative to the application directory. - - C{None} if the plugin is not found. + - ``None`` if the plugin is not found. """ server_path, client_path = get_reference_paths() @@ -440,7 +440,7 @@ def get_reference_paths(): - The local path is relative to the applications directory. It is useful on the client-side - :returns: tuple -- C{("applications/myapp", "/myapp")} + :returns: tuple -- ``("applications/myapp", "/myapp")`` """ server_path = os.path.join('applications', current.request.application) @@ -450,7 +450,7 @@ def get_reference_paths(): def get_set_field(field): - """Get the list of the set data for the C{field} when defines. + """Get the list of the set data for the ``field`` when defines. :type field: gluon.dal.Field :param field: @@ -481,16 +481,16 @@ def get_script_path(plugin): - via the configuration parameter of the plugin_dbui B{Via the default value:} - - the default script is located in C{static/plugin_dbui/main.js} + - the default script is located in ``static/plugin_dbui/main.js`` B{Via the URL:} - - the URL should contain the argument C{script=foo} or C{script=foo.js} - - the script is search in C{app_script_dir}, one of the C{plugin_dbui} + - the URL should contain the argument ``script=foo`` or ``script=foo.js`` + - the script is search in ``app_script_dir``, one of the ``plugin_dbui`` configuration parameters. B{Via plugin_dbui configuration:} - - the script path is defined by the C{plugin_dbui} - configuration parameters C{app_script}. + - the script path is defined by the ``plugin_dbui`` + configuration parameters ``app_script``. :type plugin: plugin instance :param plugin: @@ -528,10 +528,10 @@ def get_script_path(plugin): def get_store_id(name): - """Build the store identifier using C{name}. + """Build the store identifier using ``name``. :type name: str - :returns: str -- C{nameStore} + :returns: str -- ``nameStore`` """ return STOREID % name @@ -542,7 +542,7 @@ def get_versions(): :returns: list of dict -- each dictionary contains the name of the software - and its version identifier. The keys are C{code} and C{version} + and its version identifier. The keys are ``code`` and ``version`` """ server_path, client_path = get_reference_paths() @@ -636,13 +636,13 @@ def get_versions(): def get_where_query(table): """Build the L{gluon.dal.Query} resolving foreign keys - for the C{table}. + for the ``table``. :type table: gluon.dal.Table :param table: :returns: - gluon.dal.Query or None -- C{None} when the table has no foreign key + gluon.dal.Query or None -- ``None`` when the table has no foreign key """ db = table._db @@ -664,7 +664,7 @@ def get_where_query(table): def is_foreign_field(field): - """Return C{True} when the C{field} is a reference field. + """Return ``True`` when the ``field`` is a reference field. :type field: gluon.dal.Field :param field: @@ -676,7 +676,7 @@ def is_foreign_field(field): def is_mathjax(): - """Return C{True} when the plugin mathjax is installed. + """Return ``True`` when the plugin mathjax is installed. :returns: bool @@ -685,8 +685,8 @@ def is_mathjax(): def is_set_field(field): - """Return C{True} when the C{field} value - should matches those of a C{set}. + """Return ``True`` when the ``field`` value + should matches those of a ``set``. :type field: gluon.dal.Field @@ -703,7 +703,7 @@ def is_set_field(field): def is_table_with_foreign_fields(table): - """Return C{True} when the database C{table} has at least + """Return ``True`` when the database ``table`` has at least one reference field. :type table: gluon.dal.Table @@ -727,7 +727,7 @@ def rows_serializer(rows): :returns: list - * C{[{Table1Field1: val1,...}, {Table1Field1: val2,...}, ...]} + * ``[{Table1Field1: val1,...}, {Table1Field1: val2,...}, ...]`` * A dictionary per row. * Field are encoded as TableField. * Field with an applied function like COUNT(table.field) diff --git a/modules/plugin_dbui/mapper.py b/modules/plugin_dbui/mapper.py index 2bab8bbe042981673a050562f3e624500bdb782e..d22bd832464cc15e169d71c884ee4e0bde12f68d 100644 --- a/modules/plugin_dbui/mapper.py +++ b/modules/plugin_dbui/mapper.py @@ -5,7 +5,7 @@ from extjs import TabPanel def map_default(fields): - """Map a list of field in the C{Ext.form.formPanel}. + """Map a list of field in the ``Ext.form.formPanel``. :type fields: list :param fields: list of database field names @@ -17,14 +17,14 @@ def map_default(fields): def map_tabpanel(fieldsets): - """Map a list of C{FieldSets} in the C{Ext.TabPanel}. + """Map a list of ``FieldSets`` in the ``Ext.TabPanel``. - A tab is associated to each fieldset. - the name of the tab is the name of the fieldset. :type fieldsets: list of FieldSet - :returns: list -- the C{TapPanel} encapsulated in a list. + :returns: list -- the ``TapPanel`` encapsulated in a list. """ diff --git a/modules/plugin_dbui/modifier.py b/modules/plugin_dbui/modifier.py index 7bd6dd7c32f09f58ad7706f7d4828a11e05ca186..0f42b13552eca55f28d349576728a7adcc27695f 100644 --- a/modules/plugin_dbui/modifier.py +++ b/modules/plugin_dbui/modifier.py @@ -18,10 +18,10 @@ class Modifier(object): """Create the L{gluon.storage.Storage} in the plugin dbui to house modifier information. - - The path to access to the Storage is defined by the C{dpname} - and C{tablename}. - - The C{Storage} is linked to the class attribute C{data}. - - The C{Storage} can be accessed outside the modifier + - The path to access to the Storage is defined by the ``dpname`` + and ``tablename``. + - The ``Storage`` is linked to the class attribute ``data``. + - The ``Storage`` can be accessed outside the modifier in the following way: >>> p = PluginManager('dbui') @@ -32,7 +32,7 @@ class Modifier(object): >>> p = PluginManager('dbui') >>> modifier = p.dbui[dpname][tablename] - - The C{Storage} contains the C{extjs} key to store + - The ``Storage`` contains the ``extjs`` key to store configuration parameter of the associate Ext JS widget. :type dpname: str @@ -67,22 +67,22 @@ class Modifier(object): - Existing value of the configuration parameters are replaced by those defined in the keyword arguments. - - The keyword argument C{plugins} contains a list of plugins. - The current list of C{plugins} are extend with the new ones - defined by the keyword argument C{plugins}. + - The keyword argument ``plugins`` contains a list of plugins. + The current list of ``plugins`` are extend with the new ones + defined by the keyword argument ``plugins``. If a plugin with the same ptype alsready exists in the list it is replaced by the new definition. - - A plugin is defined by a string containing is C{pType}. + - A plugin is defined by a string containing is ``pType``. - - A plugin is defined by a dictionary containing the C{pType} + - A plugin is defined by a dictionary containing the ``pType`` and the plugin configuration options:: {'ptype': foo, 'option1': val,...} - The widget associated by default is replaced by a new one - when the keyword argument C{xtype} is used. + when the keyword argument ``xtype`` is used. """ T = current.T diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py index 28ff8cc0297b50f0eb3a5c178f62676855373108..368d05279363af6fd6a49c5b10e6777499c78037 100644 --- a/modules/plugin_dbui/navtree.py +++ b/modules/plugin_dbui/navtree.py @@ -1,4 +1,4 @@ -""" the C{Node} class to build navigation tree. +""" the ``Node`` class to build navigation tree. """ @@ -7,7 +7,7 @@ from gluon import current class Node(object): - """The C{node} is the key element of the navigation tree. + """The ``node`` is the key element of the navigation tree. It contains children (leaves) which are associated to widgets. The widget will be display on the panel of the T(Viewport). @@ -85,9 +85,9 @@ class Node(object): :returns: dict - - C{text} (str): name of the node + - ``text`` (str): name of the node - - C{children} (list): list of dictionary containing + - ``children`` (list): list of dictionary containing Ext JS configuration for the widgets associated to the leaves. """ diff --git a/modules/plugin_dbui/selector.py b/modules/plugin_dbui/selector.py index cd6eb0b9b120ec3bf7927b86bc198f6cf2c07f9c..75fa129ed2a01cfbce1dc5881eb5817ac4de4954 100644 --- a/modules/plugin_dbui/selector.py +++ b/modules/plugin_dbui/selector.py @@ -1,12 +1,12 @@ """ basic tool to build report. A report relies on three main components: - - The C{form} associated to a database table. + - The ``form`` associated to a database table. It allows the user to defined requirements. The table is built using a virtual database. - - The C{selector} running in a controller to decode the user requirements + - The ``selector`` running in a controller to decode the user requirements and to select records in the database accordingly. - - A C{view} to render the selected records. + - A ``view`` to render the selected records. A powerful mechanism is in place to render the report in different format like HTML, CSV, .... It relies on the Selector class, on the IFRAME and @@ -154,7 +154,7 @@ class Selector(Storage): - inner join for reference fields, - selector constraints, - extra queries added via the L{append_query} method. - - the C{extfield} as well as fields in the C{exclude_fields} + - the ``extfield`` as well as fields in the ``exclude_fields`` tuple are not take into account in the query. :type table: gluon.dal.Table @@ -224,7 +224,7 @@ class Selector(Storage): """Select the records of the table according to the selector constraints and to the extra queries. - - The C{extfield} as well as the fields in the C{exclude_fields} + - The ``extfield`` as well as the fields in the ``exclude_fields`` tuple are not take into account in the underlying query. - It returns Rows which contains reference tables and columns. diff --git a/modules/plugin_dbui/storemodifier.py b/modules/plugin_dbui/storemodifier.py index 6f3dbb81e5e4f0f72d46843e7f9a06627ff1418d..c21563c51302e71c052c1f52178d2c84573defde 100644 --- a/modules/plugin_dbui/storemodifier.py +++ b/modules/plugin_dbui/storemodifier.py @@ -18,10 +18,10 @@ class AddStore(object): The Ext JS configuration options of all stores are kept in a persistent dictionary of the plugin_dbui. The configuration options are transported - to the client using the C{plugin_dbui/dbui_conf} action. + to the client using the ``plugin_dbui/dbui_conf`` action. From time to time, it is useful to defined static store, - like C{Ext.data.ArrayStore}. This tool allows to defined them + like ``Ext.data.ArrayStore``. This tool allows to defined them and to add their configuration to the persistent dictionary. Thus they can be retrieve by the client in the standard way. @@ -38,13 +38,13 @@ class AddStore(object): The keyword arguments contains the configuration options for the store. - For an C{Ext.data.ArrayStore} the keyword C{fields} and C{data} + For an ``Ext.data.ArrayStore`` the keyword ``fields`` and ``data`` have to be defined. For more details see the ExtJS documentation. :note: The key associated to this store in the persistent dictionary - is the C{storeId}. Its value is derived from the store name, - I{i.e} C{nameStore}. + is the ``storeId``. Its value is derived from the store name, + I{i.e} ``nameStore``. """ static_stores = PluginManager('dbui').dbui.static_stores @@ -61,7 +61,7 @@ class StoreModifier(Modifier): def __init__(self, tablename): """Initialize the store modifier associated to the database - table C{tablename}. + table ``tablename``. The data structure of the store modifier can be access outside the class: @@ -69,13 +69,13 @@ class StoreModifier(Modifier): >>> p = PluginManager('dbui') >>> modifier = p.dbui['modifier_stores'][tablename] - or internally via the attribute C{data}. + or internally via the attribute ``data``. - The keys of the C{data} structure are: + The keys of the ``data`` structure are: - - C{extjs} (dict) Ext JS configuration options for the store widget. + - ``extjs`` (dict) Ext JS configuration options for the store widget. - - C{order_by} (list of gluon.dal.Field) list of fields to order + - ``order_by`` (list of gluon.dal.Field) list of fields to order the content of the store :type tablename: str @@ -112,10 +112,10 @@ class StoreModifier(Modifier): That means that only 5 pages are kept in the cache. Therefore this is a good option to manipulate almost infinite set of data. - :param kwargs: Any configuration parameter of the C{Ext.data.Store}. - Those related to the buffering are C{buffered}, C{clearOnPaqgeLoad}, - C{leadingBufferZone}, C{pageSize}, C{purgePageCount} - and C{trailingBufferZone}. + :param kwargs: Any configuration parameter of the ``Ext.data.Store``. + Those related to the buffering are ``buffered``, ``clearOnPaqgeLoad``, + ``leadingBufferZone``, ``pageSize``, ``purgePageCount`` + and ``trailingBufferZone``. """ di = dict(autoLoad=False, diff --git a/modules/plugin_dbui/viewportmodifier.py b/modules/plugin_dbui/viewportmodifier.py index bfbc40571e86f19652a96a336430cf916e769c62..acefb6e99e0ea7b559985204b67a1177fc236ea5 100644 --- a/modules/plugin_dbui/viewportmodifier.py +++ b/modules/plugin_dbui/viewportmodifier.py @@ -26,17 +26,17 @@ class ViewportModifier(Modifier): >>> p = PluginManager('dbui') >>> modifier = p.dbui['modifier_viewports'] - or internally via the attribute C{data}. + or internally via the attribute ``data``. - The keys of the C{data} structure are: + The keys of the ``data`` structure are: - - C{default} (list) list of node defining the path of the node + - ``default`` (list) list of node defining the path of the node which will be opened at start up. Each node is identify its - C{text} string. + ``text`` string. - - C{extjs} (dict) Ext JS configuration options for the viewport widget. + - ``extjs`` (dict) Ext JS configuration options for the viewport widget. - - C{nodes} (list) list of L{Node} defining the navigation tree + - ``nodes`` (list) list of L{Node} defining the navigation tree """ Modifier.__init__(self, MODIFIER_VIEWPORTS) @@ -54,11 +54,11 @@ class ViewportModifier(Modifier): :type args: list of L{Node} :param args: - :note: Elements of the list equal to C{None} are ignored. + :note: Elements of the list equal to ``None`` are ignored. This feature is useful when the list of nodes depend on user role. :raise ViewportModifierException: at least one element of the list - is not a C{Node} or C{None}. + is not a ``Node`` or ``None``. """ li = [] @@ -79,7 +79,7 @@ class ViewportModifier(Modifier): def default_node(self, *args): """Defined the node which will be opened at start up. - :type args: list of nodes identified by their C{text} string. + :type args: list of nodes identified by their ``text`` string. :param args: define the path of the node """