diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py index 2c5a1417b63993eb05a2f70032266f02249b71e1..8a6bd239c8c105a7295372366fae37dbe2466723 100644 --- a/modules/plugin_dbui/dbsvc.py +++ b/modules/plugin_dbui/dbsvc.py @@ -53,56 +53,48 @@ class DbSvc(BaseSvc): The main methods allow to: - - ``create`` a new record in a table. - - - ``read`` the content of a a table - resolving foreign key. - - - ``update`` the record of a table. - - - ``destroy`` the record of a table. + * ``create`` a new record in a table. + * ``read`` the content of a a table resolving foreign key. + * ``update`` the record of a table. + * ``destroy`` the record of a table. - These methods receive transaction data dictionary, ``arg``: + .. _input transaction dictionary: + + These methods receive the *transaction data dictionary*, ``arg``: - - ``tableName`` - the name of the table in the database - - - ``dbFields`` + * ``tableName`` the name of the table in the database - - ``[["table1", "field1"], ... ]`` - - - The list of database fields of the table. - - - Include foreign keys and reference fields. + * ``dbFields`` The list of database fields of the table, + ``[["table1", "field1"], ... ]`` including foreign keys + and reference fields. - - ``records`` (optional) - - - ``[{"Table1Field1": val1,...}]`` - - - A list of dictionaries containing key, value pairs for fields - to be created or updated + * ``records`` (optional) A list of dictionaries containing key, + value pairs for fields to be created or updated, + ``[{"Table1Field1": val1,...}]`` including foreign key and + reference field values. Each dictionary also contains + the ``id`` of the record to be updated. - - Includes foreign key and reference field values. - - - Contains the ``id`` of the record to be updated. - - - The keys are encoded as ``Table1Field1``. + The keys are encoded as ``Table1Field1``. - - The ``records`` can also be a list containing the ``id`` of the - records to be deleted. + The ``records`` can also be a list containing the ``id`` of the + records to be deleted. - Each method return a dictionary: - - - ``{success: True, records:[{blabla}, ..], msg: 'blalbla'}`` + .. _output transaction dictionary: + + Each method return the dictionary:: + + {success: True, records:[{blabla}, ..], msg: 'blalbla'} - - 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 ``TableField``. + * 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. + + * The keys of the ``record`` dictionary are the database fields + encoded as ``TableField``. - - If the action failed the ``DbSvcException`` is raised. - The exception can be catch to generate an HTTP error. + The ``DbSvcException`` is raised when the action failed. + It can be caught to generate an HTTP error. """ @@ -111,35 +103,7 @@ class DbSvc(BaseSvc): contains the ``keywords``. :type arg: dict - :param arg: - transaction data - - - ``tableName`` - the name of the table in the database - - - ``dbFields`` - - - ``[["table1", "field1"], ... ]`` - - - The list of database fields of the table. - - - Include foreign keys and reference fields. - - - ``records`` (optional) - - - ``[{"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 ``id`` of the record to be updated. - - - The keys are encoded as ``Table1Field1``. - - - The ``records`` can also be a list containing the ``id`` of the - records to be deleted. + :param arg: :ref:`input transaction dictionary <input transaction dictionary>` :type keywords: dict @@ -177,10 +141,11 @@ class DbSvc(BaseSvc): "([table1.field1] == [table2.field2]) | ([table1.field2] == [table2.field1])" :returns: - tuple of gluon.dal.Query --: - - 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 third element contains only the filter conditions or an empty string. + tuple of gluon.dal.Query + + * 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 third element contains only the filter conditions or an empty string. :note: All elements of the list are ANDED in the web2py query @@ -341,46 +306,21 @@ class DbSvc(BaseSvc): The method also validates each value. :type arg: dict - :param arg: - transaction data - - - ``tableName`` - the name of the table in the database - - - ``dbFields`` - - - ``[["table1", "field1"], ... ]`` - - - The list of database fields of the table. - - - Include foreign keys and reference fields. - - - ``records`` - - - ``[{"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 ``id`` of the record to be updated. - - - The keys are encoded as ``Table1Field1``. + :param arg: :ref:`input transaction dictionary <input transaction dictionary>` :returns: gluon.storage.Storage - - ``Storage(errors=[], records=[])`` + * ``Storage(errors=[], records=[])`` - - One to one correspondence between the errors + * One to one correspondence between the errors and the records lists - - ``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 ``Table1Field1``. - - The ``error`` is ``None`` when the ``record`` is validated. + * The ``error`` is ``None`` when the ``record`` is validated. Otherwise the error is a dictionary ``{Table1Field1: "error message", ...}`` @@ -430,51 +370,17 @@ class DbSvc(BaseSvc): Several transactions of the same type are processed together. :type arg: dict - :param arg: - transaction data - - - ``tableName`` - the name of the tablename in the database - - - ``dbFields`` - - - ``[["table1", "field1"], ... ]`` - - - The list of database fields of the tablename. - - - Include foreign keys and reference fields. - - - ``records`` - - - ``[{"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 ``Table1Field1``. + :param arg: :ref:`input transaction dictionary <input transaction dictionary>` - :returns: - dict - - - ``{success: True, records:[{Table1Field1: val, ... }, ... ], - msg: 'blalbla'}`` - - - ``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 ``Table1Field1``. + :returns: + :ref:`output transaction dictionary <output transaction dictionary>` - - ``{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 ``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 ``Table1Field1`` while the value is - the error message. + The full transaction is aborted when at least one field value + is not validated by the database engine or when the transaction + is killed by the callback ``table._before_insert``. + In that scenario, the ``errors`` key contains either a string, + the error message return by callback, or the dictionary returns + by the validator. """ self.dbg("Start DbSvc.create") @@ -528,38 +434,22 @@ class DbSvc(BaseSvc): :type arg: dict :param arg: - transaction data + :ref:`input transaction dictionary <input transaction dictionary>` - - ``tableName`` - the name of the tablename in the database - - - ``dbFields`` - - - ``[["table1", "field1"], ... ]```` - - - The list of database fields of the tablename. - - - Include foreign keys and reference fields. - - - ``records`` the list of ``id`` for the records - to be deleted, ``[id1, id2, ... ]``. + The key ``records`` is the list of ``id`` to be deleted + *e.g.* ``[id1, id2, ... ]``. :returns: - dict + :ref:`output transaction dictionary <output transaction dictionary>` - - ``{success: True, records:[{Table1Id1: id}, ...], msg: 'blalbla'}`` - - ``records`` is a list of dictionary containing the ``id`` - of the delete records: ``[{TableId:xx}, ..]``. + * The key``records`` is a list of dictionary containing the ``id`` + of the delete records *e.g.* ``[{TableId:xx}, ..]``. - - The record key are encoded as ``Table1Field1``. - - - ``{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 ``table._before_delete``. - The full transaction is aborted. - The errors contains the error messages return by the callback. + * The full transaction is aborted when either one record does + not exist or when the delete operation is rejected by the + callback ``table._before_delete``. The ``errors`` key + contains the error messages return by the callback. """ self.dbg("Start DbSvc.destroy") @@ -608,58 +498,35 @@ class DbSvc(BaseSvc): :type arg: dict :param arg: - transaction data + :ref:`input transaction dictionary <input transaction dictionary>` - - ``tableName`` - the name of the table in the database - - - ``dbFields`` + * The *optional* key ``where`` (optional) is a list of string + to build the inner join when handling foreign key:: - - ``[["table1", "field1"], ... ]`` + ['db.table1.field1 == db.table2.id', ... ] - - The list of database fields of the table. - - - Include foreign keys and reference fields. - - - ``where`` (optional) - - - ``['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: - ``db.table1.field1 == db.table2.id``. - - - An AND is performed between the different - elements of the list. + The string syntax follows the web2py convention: + ``db.table1.field1 == db.table2.id``. An AND is performed + between the different elements of the list. - - ``orderby`` (optional) + * the *optional* key ``orderby`` is a list of tuples to build + the order directive:: - - ``[("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 ``"ASC"`` or ``"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: - - page - - start - - limit - - sort - - dir + * The transaction dictionary can also contains parameters useful + for paging. For more detail see the Ext.PagingToolbar + configuration parameters: ``page``, ``start``, ``limit``, + ``sort`` and ``dir``. :returns: - dict + :ref:`output transaction dictionary <output transaction dictionary>` - - ``{success: True, records: [{TableField: value, ...}, ...]}`` - - - ``records`` is a list of dictionary containing the key value - pairs for the record found in the database. + The key ``records`` is a list of dictionary containing the key value + pairs for the record found in the database. - - the record keys are encoded as ``Table1Field1``. - """ self.dbg("Start DbSvc.read") @@ -736,53 +603,26 @@ class DbSvc(BaseSvc): Several transactions of the same type are processed together. :type arg: dict - :param arg: - transaction data + :param arg: + :ref:`input transaction dictionary <input transaction dictionary>` - - ``tableName`` - the name of the tablename in the database - - - ``dbFields`` - - - ``[["table1", "field1"], ... ]`` - - - The list of database fields of the tablename. - - - Include foreign keys and reference fields. - - - ``records`` - - - ``[{"Table1Field1": val1,...}]`` - - - A list of dictionaries containing key, value pairs for fields - to be updated - - - Includes foreign key and reference field values. - - - Contains the ``id`` of the record to be updated. - - - The keys are encoded as ``Table1Field1``. + the key ``records`` is the list of dictionaries one per record to + be updated. Each dictionary contains key, value pairs for fields + to be updated as well as the record ``id``. :returns: - dict + :ref:`output transaction dictionary <output transaction dictionary>` - - ``{success: True, records:[{Table1Field1: val, ... }, ... ], - msg: 'blalbla'}`` - - - ``records`` is a list of dictionary containing the complete + * the key ``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 ``Table1Field1``. - - - ``{success: False, records:[{Table1Field1: val, ... }, ... ], - errors: 'blabla', }`` - when at least a field value is not validated or when the transaction + * The full transaction is aborted when either a field value is not + validated by the database engine or when the transaction 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 + The *errors* key contains the error message return by callback or + a dictionary returns by the validator (the key is the field identifier encoded as ``Table1Field1`` while the value is - the error message. + the error message). """ self.dbg("Start DbSvc.update.") diff --git a/modules/plugin_dbui/directsvc.py b/modules/plugin_dbui/directsvc.py index 683adfcc6e64e3e6a9fed9a167bda67d87c79224..3809d85782390e670e42942f51d806b5b79383d5 100644 --- a/modules/plugin_dbui/directsvc.py +++ b/modules/plugin_dbui/directsvc.py @@ -54,13 +54,13 @@ class DirectSvc(BaseSvc): On the client-side: - - the API definition can be retrieved using the + * the API definition can be retrieved using the URL: ``/myapplication/plugin_dbui/call/get_api`` - - the URL to send requests is + * the URL to send requests is ``/myapplication/plugin_dbui/call`` - - remote functions and methods can be call in the + * remote functions and methods can be call in the following way ``Dbui.myfunction(a, b, callback)`` and ``MyClass.mymethod(c, d, callback)`` respectively. @@ -84,9 +84,9 @@ class DirectSvc(BaseSvc): :returns: str - - the response of the function / method run + * the response of the function / method run on the server side - - the response is encoded as a JSON string. + * the response is encoded as a JSON string. :raise gluon.http.HTTP: when the request has no arguments @@ -157,7 +157,7 @@ class DirectSvc(BaseSvc): def route(self): - """Route the myrequest to the appropriate function / method, + """Route the request to the appropriate function / method, pass the proper arguments and return the results. :returns: @@ -165,9 +165,9 @@ class DirectSvc(BaseSvc): encoded as a JSON string. :raise gluon.http.HTTP: - - with the code 500 when - the execution of the function / method crash. - - the python trace back is stored in the web2py ticket system. + with the code 500 when the execution of the + function / method crash. The python trace back is stored + in the web2py ticket system. """ self.dbg('Start directSvc.route') diff --git a/modules/plugin_dbui/fieldsmodifier.py b/modules/plugin_dbui/fieldsmodifier.py index 53b3871e48f126e1b20422ea1e28eb4ed0eff397..d8d6a0fbfbcda942db56c6fb6e5f8b0d960280cb 100644 --- a/modules/plugin_dbui/fieldsmodifier.py +++ b/modules/plugin_dbui/fieldsmodifier.py @@ -19,25 +19,25 @@ class FieldsModifier(Modifier): table ``tablename``. The data structure of the fields modifier can be access - outside the class: + outside the class:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui['modifier_fields'][tablename] + p = PluginManager('dbui') + modifier = p.dbui['modifier_fields'][tablename] or internally via the attribute ``data``. The keys of the ``data`` structure are: - - ``extjs_fields`` (dict) Ext JS configuration options + * ``extjs_fields`` (dict) Ext JS configuration options for individual ``field``. - - ``composite_fields.main`` (list) the first field + * ``composite_fields.main`` (list) the first field of the ``FieldContainer``. - - ``composite_fields.others`` (list of list) the others field of + * ``composite_fields.others`` (list of list) the others field of the ``FieldContainer``. - - There is one to one correspondence between the ``composite_fields.main`` + * There is one to one correspondence between the ``composite_fields.main`` and the ``composite_fields.others`` lists. :type tablename: str @@ -97,10 +97,10 @@ class FieldsModifier(Modifier): They can be super seed by the keyword arguments. :note: - - 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 + * 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 ``Ext.form.FieldContainer`` widget. """ diff --git a/modules/plugin_dbui/formmodifier.py b/modules/plugin_dbui/formmodifier.py index 708c457667c90ce88fc89836ebd4b69f6046756c..8cca0582c665455241b195dbb1d1a93f3420c42d 100644 --- a/modules/plugin_dbui/formmodifier.py +++ b/modules/plugin_dbui/formmodifier.py @@ -53,29 +53,29 @@ class FormModifier(Modifier): table ``tablename``. The data structure of the form modifier can be access - outside the class: + outside the class:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui['modifier_forms'][tablename] + p = PluginManager('dbui') + modifier = p.dbui['modifier_forms'][tablename] or internally via the attribute ``data``. The keys of the ``data`` structure are: - - ``extjs`` (dict) Ext JS configuration options for the form widget. + * ``extjs`` (dict) Ext JS configuration options for the form widget. - - ``field_sets`` (list of Storage) each ``Storage`` defined a + * ``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 ``Ext.form.FieldSet`` widget. - - ``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. + * ``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. - - ``mapper`` (None or function) reference to the function used - to organize the ``FieldSet`` in ``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 @@ -93,12 +93,12 @@ class FormModifier(Modifier): """Link two fields in such a way that the values available for the second one depend on the value selected for the first one. - - This first field is the master while the second one is the slave. - - Often the master and slave fields are reference fields. - - An external table contains the data defining the relation between the + * This first field is the master while the second one is the slave. + * Often the master and slave fields are reference fields. + * An external table contains the data defining the relation between the master and the slave. - - The external table must have the master and slave fields - - Several slaves can be attached to the same master:: + * The external table must have the master and slave fields + * Several slaves can be attached to the same master:: fieldsModifier = fieldsModifier('mytable') fieldsModifier.link_comboxes(master=virtdb.mytable.myfield1, @@ -108,7 +108,7 @@ class FormModifier(Modifier): slave=virtdb.mytable.myfield3, masterHasSlaveData='anotherTable') - - This method modify deeply the field configuration transforming + * This method modify deeply the field configuration transforming the Ext.form.comboBox into App.form.LinkedComboBox. :type master: gluon.dal.Field diff --git a/modules/plugin_dbui/gridmodifier.py b/modules/plugin_dbui/gridmodifier.py index d4c0c15a629a7b81d5519955195d39c40459b57a..a7bc9effef4eaeebfa8dfad1c899019246b895be 100644 --- a/modules/plugin_dbui/gridmodifier.py +++ b/modules/plugin_dbui/gridmodifier.py @@ -57,30 +57,30 @@ class GridModifier(Modifier): table ``tablename``. The data structure of the grid modifier can be access - outside the class: + outside the class:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui['modifier_grids'][tablename] + p = PluginManager('dbui') + modifier = p.dbui['modifier_grids'][tablename] or internally via the attribute ``data``. The keys of the ``data`` structure are: - - ``extjs`` (dict) Ext JS configuration options for the grid widget. + * ``extjs`` (dict) Ext JS configuration options for the grid widget. - - ``configure_columns`` (dict) the Ext JS configuration options for + * ``configure_columns`` (dict) the Ext JS configuration options for the ``Ext.grid.Column`` widget. The column is identify by its ``fieldname``. - - ``delete_columns`` (list) + * ``delete_columns`` (list) - - ``grid_filters`` (storage) + * ``grid_filters`` (storage) - - ``hidden_columns`` (list) + * ``hidden_columns`` (list) - - ``row_numbering`` (bool) + * ``row_numbering`` (bool) - - ``template_columns`` (list + * ``template_columns`` (list :type tablename: str :param tablename: name of the database table @@ -127,13 +127,13 @@ class GridModifier(Modifier): :param filter: A filter is defined by a tuple containing three strings: - - The database field name. The field has to + * The database field name. The field has to belong to the database table defined in the constructor. However, the more elaborate syntax, ``'table2.field1'``, allows to use foreign field. - - The operator, ``'=='``, ``'contains'``, ... + * The operator, ``'=='``, ``'contains'``, ... Valid operator are defined in the method L{dbsvc.DbSvc._encode_query} - - The comment for the tool tip. + * The comment for the tool tip. The keyword argument contains Ext JS configuration options for the associated Ext.form.Field. @@ -215,14 +215,14 @@ class GridModifier(Modifier): the template defining how fields are displayed in the TemplateColumn. - - The syntax of the template is is defined in the documentation + * The syntax of the template is is defined in the documentation of ``Ext.XTemplate`` constructor. - - There is some limitation when defining the template in python, + * There is some limitation when defining the template in python, namely the use of the template member function. - - Database fields are identified using the ``CapWord`` syntax: + * 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:: + * HTML balises are understood. + * Example of a template list:: tpl = ['<b>{PeopleLast_name}</b><br>', '{PeopleFirst_name}<br>', diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index 1f1eb55761761bafcacaba8a6a2ce3c609289405..1ca1f754e7a995a813c29637d221fc1f17590847 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -61,8 +61,9 @@ def decode_field(field): of words where all words are in lower case. The reverse function is L{encode_field}. - :note: useful to decode database field name: - ``"TableField"`` or ``"TableFieldFunction"`` + :note: + useful to decode database field name: + ``TableField`` or ``TableFieldFunction`` :type field: str :param field: @@ -266,16 +267,11 @@ def get_file_paths(path, ext=None, alpha=True): :param path: local path defining the target files: - - ``None``. - - - a ``string`` pointing to one files. - - - a ``list`` of strings pointing to several files. - - - a ``string`` pointing to a directory. - - - a ``list`` of string pointing to files and directory. - + * ``None``. + * a ``string`` pointing to one files. + * a ``list`` of strings pointing to several files. + * a ``string`` pointing to a directory. + * a ``list`` of string pointing to files and directory. :type ext: str :param ext: @@ -321,19 +317,19 @@ def get_foreign_field(field): :returns: tuple - - ``(k_tablename, k_fieldname, k_keyname)`` + * ``(k_tablename, k_fieldname, k_keyname)`` - - ``k_tablename`` is the name of the reference table + * ``k_tablename`` is the name of the reference table - - ``k_fieldname`` is the name of the reference field, I{i.e} + * ``k_fieldname`` is the name of the reference field, I{i.e} ``table.field`` S{->} ``k_table.k_field`` - - ``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, ``table.field == k_table.k_key``. In almost all case ``k_key`` is equal to ``id``. - - ``None`` for standard field. + * ``None`` for standard field. """ if not is_foreign_field(field): @@ -424,9 +420,9 @@ def get_plugin_path(plugin_name): :returns: str - - the path of the first directory starting with ``plugin_name``. - - the local path is relative to the application directory. - - ``None`` if the plugin is not found. + * the path of the first directory starting with ``plugin_name``. + * the local path is relative to the application directory. + * ``None`` if the plugin is not found. """ server_path, client_path = get_reference_paths() @@ -445,9 +441,9 @@ def get_plugin_path(plugin_name): def get_reference_paths(): """Get a tuple with the absolute and local paths: - - The absolute path is relative to the web2py directory. + * The absolute path is relative to the web2py directory. It is useful on the server-side - - The local path is relative to the applications directory. + * The local path is relative to the applications directory. It is useful on the client-side :returns: tuple -- ``("applications/myapp", "/myapp")`` @@ -479,27 +475,27 @@ def get_set_field(field): def get_script_path(plugin): """Get the local path of the main javascript script to be - ran on the client-side. + ran on the client-side:: - >>> import plugin_dbui as dbui - >>> plugin = plugins.dbui - >>> path = dbui.get_script_path(plugin) + import plugin_dbui as dbui + plugin = plugins.dbui + path = dbui.get_script_path(plugin) The main script can be selected in several ways: - - via the default script - - via the URL calling the application - - via the configuration parameter of the plugin_dbui + * via the default script + * via the URL calling the application + * via the configuration parameter of the plugin_dbui B{Via the default value:} - - the default script is located in ``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 ``script=foo`` or ``script=foo.js`` - - the script is search in ``app_script_dir``, one of the ``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 ``plugin_dbui`` + * the script path is defined by the ``plugin_dbui`` configuration parameters ``app_script``. :type plugin: plugin instance @@ -508,8 +504,8 @@ def get_script_path(plugin): :returns: str - - the local path of the script file - - the local paths is relative to the application directory. + * the local path of the script file + * the local paths is relative to the application directory. """ server_path, client_path = get_reference_paths() diff --git a/modules/plugin_dbui/mapper.py b/modules/plugin_dbui/mapper.py index f52f4f5cd57fcc2c60b913a9e0f1aa38a60fb4cc..f4393cfa897ad4d2b333bb7c9f77a132f72289f4 100644 --- a/modules/plugin_dbui/mapper.py +++ b/modules/plugin_dbui/mapper.py @@ -19,8 +19,8 @@ def map_default(fields): def map_tabpanel(fieldsets): """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. + * A tab is associated to each fieldset. + * the name of the tab is the name of the fieldset. :type fieldsets: list of FieldSet :param fieldsets: diff --git a/modules/plugin_dbui/modifier.py b/modules/plugin_dbui/modifier.py index 0f42b13552eca55f28d349576728a7adcc27695f..5c01894882deb59227976767bafcbd6e056b6a77 100644 --- a/modules/plugin_dbui/modifier.py +++ b/modules/plugin_dbui/modifier.py @@ -18,21 +18,21 @@ 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 ``dpname`` + * 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: + * The ``Storage`` is linked to the class attribute ``data``. + * The ``Storage`` can be accessed outside the modifier + in the following way:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui[dpname] + p = PluginManager('dbui') + modifier = p.dbui[dpname] - or when the tablename is defined: + or when the tablename is defined:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui[dpname][tablename] + p = PluginManager('dbui') + modifier = p.dbui[dpname][tablename] - - The ``Storage`` contains the ``extjs`` key to store + * The ``Storage`` contains the ``extjs`` key to store configuration parameter of the associate Ext JS widget. :type dpname: str @@ -64,24 +64,24 @@ class Modifier(object): """Set the configuration parameters for the associated Ext JS widget. :note: - - Existing value of the configuration parameters are replaced by + * Existing value of the configuration parameters are replaced by those defined in the keyword arguments. - - The keyword argument ``plugins`` contains a list of 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 ``pType``. + * A plugin is defined by a string containing is ``pType``. - - A plugin is defined by a dictionary containing the ``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 + * The widget associated by default is replaced by a new one when the keyword argument ``xtype`` is used. """ diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py index f8497223b09b07c7783be1c1efcfba9f635f2eb2..65aa3fa5eea3976ae5bde7cbd4f351f9c2c99a64 100644 --- a/modules/plugin_dbui/navtree.py +++ b/modules/plugin_dbui/navtree.py @@ -56,8 +56,8 @@ class Node(object): :param hidden: List of children to be hidden. :note: - - Leaf names are translated in the current language - - Leaf names are sorted in alphabetic order + * Leaf names are translated in the current language + * Leaf names are sorted in alphabetic order """ # translator @@ -87,9 +87,8 @@ class Node(object): :returns: dict - - ``text`` (str): name of the node - - - ``children`` (list): list of dictionary containing + * ``text`` (str): name of the node + * ``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 882b190697a012d27ec4ecf14ee1e9880af353cf..71840e941afefc87c08e2e83dbf625315edc216f 100644 --- a/modules/plugin_dbui/selector.py +++ b/modules/plugin_dbui/selector.py @@ -31,21 +31,21 @@ from helper import (decode_field, class Selector(Storage): - """Basic tool to build a report. + """Basic tool to build a report: - - Decode the data send by the selector widget. - - Build the query for a given table of the database. - - Select Rows for a given table of the database. + * Decode the data send by the selector widget. + * Build the query for a given table of the database. + * Select Rows for a given table of the database. This class handle table and its reference field. The basic query handles the selector constraints and the inner join for reference field. Additional constraints can also be added via the method L{append_query}. - All fields of the selector are attributes of this class: + All fields of the selector are attributes of this class:: - >>> value = myselector.myfield - >>> value = myselector['myfield'] + value = myselector.myfield + value = myselector['myfield'] The type of the return value is the type of the field defined in the model. @@ -153,10 +153,11 @@ class Selector(Storage): def query(self, table): """Build the database query for the database table. It includes: - - inner join for reference fields, - - selector constraints, - - extra queries added via the L{append_query} method. - - the ``extfield`` as well as fields in the ``exclude_fields`` + + * inner join for reference fields, + * selector constraints, + * extra queries added via the L{append_query} method. + * the ``extfield`` as well as fields in the ``exclude_fields`` tuple are not take into account in the query. :type table: gluon.dal.Table @@ -227,10 +228,10 @@ class Selector(Storage): """Select the records of the table according to the selector constraints and to the extra queries. - - The ``extfield`` as well as the fields in the ``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. + * It returns Rows which contains reference tables and columns. :type table: gluon.dal.Table :param table: diff --git a/modules/plugin_dbui/storemodifier.py b/modules/plugin_dbui/storemodifier.py index 4d59d546e15e14d52dcff39b8ddbe39a40828bcb..119ea441fd281b09792ce4d6865f8cf069606737 100644 --- a/modules/plugin_dbui/storemodifier.py +++ b/modules/plugin_dbui/storemodifier.py @@ -64,18 +64,17 @@ class StoreModifier(Modifier): table ``tablename``. The data structure of the store modifier can be access - outside the class: + outside the class:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui['modifier_stores'][tablename] + p = PluginManager('dbui') + modifier = p.dbui['modifier_stores'][tablename] or internally via the attribute ``data``. The keys of the ``data`` structure are: - - ``extjs`` (dict) Ext JS configuration options for the store widget. - - - ``order_by`` (list of gluon.dal.Field) list of fields to order + * ``extjs`` (dict) Ext JS configuration options for the store widget. + * ``order_by`` (list of gluon.dal.Field) list of fields to order the content of the store :type tablename: str @@ -99,12 +98,12 @@ class StoreModifier(Modifier): """ The store is buffered. The method set the following configuration options: - - autoLoad = False - - buffered = True - - clearOnPageLoad = True - - pageSize = 25 - - leadingBufferZone = 0 - - trailingBufferZone = 0 + * autoLoad = False + * buffered = True + * clearOnPageLoad = True + * pageSize = 25 + * leadingBufferZone = 0 + * trailingBufferZone = 0 They can be overwritten using the keyword arguments. diff --git a/modules/plugin_dbui/viewportmodifier.py b/modules/plugin_dbui/viewportmodifier.py index 5cdcef05191957c20f149007427852675a4c9623..a5edcd4f601eca4c98980ea45259f5b73f8a14d1 100644 --- a/modules/plugin_dbui/viewportmodifier.py +++ b/modules/plugin_dbui/viewportmodifier.py @@ -21,22 +21,23 @@ class ViewportModifier(Modifier): """Initialize the viewport modifier associated to the application. The persistent data structure of the viewport modifier can be access - outside the class: + outside the class:: - >>> p = PluginManager('dbui') - >>> modifier = p.dbui['modifier_viewports'] + p = PluginManager('dbui') + modifier = p.dbui['modifier_viewports'] or internally via the attribute ``data``. The keys of the ``data`` structure are: - - ``default`` (list) list of node defining the path of the node - which will be opened at start up. Each node is identify its - ``text`` string. + * ``default`` (list) list of node defining the path of the node + which will be opened at start up. Each node is identify its + ``text`` string. - - ``extjs`` (dict) Ext JS configuration options for the viewport widget. + * ``extjs`` (dict) Ext JS configuration options for the + viewport widget. - - ``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)