1.1.1.2. gnr.app.gnrdbo – Counters, tables and other services for the hierarchical database

1.1.1.2.2. GnrDboTable

1.1.1.2.9. gnr.app.gnrdbo - The complete reference list

class gnr.app.gnrdbo.GnrDboPackage

Base class for packages

deleteUserObject(id, pkg=None)

TODO

Parameters:
  • id – the object id
  • pkg – the package object
getCounter(name, code, codekey, output, date=None, phyear=False, lastAssigned=0)

Generate a new number from the specified counter and return it.

Parameters:
  • name – the counter name
  • code – the counter code
  • codekey – the codekey format (e.g. $YY for year)
  • output – the output format (e.g. $YY.$NNNN for year)
  • date – the current date
  • phyear – the fiscal year
  • lastAssigned – TODO
getLastCounterDate(name, code, codekey, output, date=None, phyear=False, lastAssigned=0)

TODO

Parameters:
  • name – the counter name
  • code – the counter code
  • codekey – the codekey format (e.g. $YY for year)
  • output – the output format (e.g. $YY.$NNNN for year)
  • date – the current date
  • phyear – the fiscal year
  • lastAssigned – TODO
getPreference(path, dflt=None)

Get a preference for the current package. Return the value of the specified preference, or dflt if it is missing

Parameters:
  • path – a dotted name of the preference item
  • dflt – the default value
listUserObject(pkg=None, **kwargs)

TODO

Parameters:pkg – the package object
loadUserObject(pkg=None, **kwargs)

TODO

Parameters:pkg – the package object
saveUserObject(data, pkg=None, **kwargs)

TODO

Parameters:
  • data – TODO
  • pkg – the package object
setCounter(name, code, codekey, output, date=None, phyear=False, value=0)

TODO

Parameters:
  • name – the counter name
  • code – the counter code
  • codekey – the codekey format (e.g. $YY for year)
  • output – the output format (e.g. $YY.$NNNN for year)
  • date – the current date
  • phyear – the fiscal year
  • value – TODO
setPreference(path, value)

Set a preference for the current package.

Parameters:
  • path – a dotted name of the preference item
  • value – the new value
updateFromExternalDb(externaldb, empty_before=None)

TODO

Parameters:
  • externaldb – TODO
  • empty_before – TODO
class gnr.app.gnrdbo.GnrDboTable

TODO

use_dbstores()

TODO

class gnr.app.gnrdbo.GnrHTable

A hierarchical table. More information on the HTable section

assignCode(record_data)

TODO

Parameters:record_data – TODO
htableFields(tbl)
Parameters:tbl – the table object

Create the necessary columns in order to use the HTableHandler component.

In particular it adds:

  • the “code” column: TODO
  • the “description” column: TODO
  • the “child_code” column: TODO
  • the “parent_code” column: TODO
  • the “level” column: TODO

You can redefine the first three columns in your table; if you don’t redefine them, they are created with the following features:

tbl.column('code', name_long='!!Code', base_view=True)
tbl.column('description', name_long='!!Description', base_view=True)
tbl.column('child_code', name_long='!!Child code', validate_notnull=True,
            validate_notnull_error='!!Required', base_view=True,
            validate_regex='!\.', validate_regex_error='!!Invalid code: "." char is not allowed')
trigger_onInserting(record_data)

TODO

Parameters:record_data – TODO
trigger_onUpdating(record_data, old_record=None)

TODO

Parameters:
  • record_data – TODO
  • old_record – TODO
class gnr.app.gnrdbo.TableBase

TODO

hasRecordTags()

TODO

setMultidbSubscription(tblname)

TODO

Parameters:tblname – a string composed by the package name and the database table name separated by a dot (.)
setTagColumn(tbl, name_long=None, group=None)

TODO

Parameters:
  • tbl – the table object
  • name_long – the name_long
  • group – a hierarchical path of logical categories and subacategories the columns belongs to. For more information, check the group section
sysFields(tbl, id=True, ins=True, upd=True, ldel=True, draftField=False, md5=False, group='zzz', group_name='!!System')

Add some useful columns for tables management (first of all, the id column)

Parameters:
  • tbl – the table object
  • id – boolean. If True, create automatically an id column. The id column is normally used as the primary key (pkey) of a table
  • ins – boolean. If True, create the __ins_ts column. Allow to know the time (date and hour) of a record entry
  • upd – boolean. If True, create the __mod_ts column. Allow to know the time (date and hour) of a record modify
  • ldel – boolean. If True, create the __del_ts column. Allow to know the time (date and hour) of a record delete
  • draftField – TODO
  • md5 – boolean. TODO
  • group – a hierarchical path of logical categories and subacategories the columns belong to. For more information, check the group section
  • group_name – TODO
trigger_setAuditVersionIns(record, fldname)

TODO

Parameters:
  • record – the record
  • fldname – the field name
trigger_setAuditVersionUpd(record, fldname)

TODO

Parameters:
  • record – the record
  • fldname – the field name
trigger_setRecordMd5(record, fldname)

TODO

Parameters:
  • record – the record
  • fldname – the field name
trigger_setTSNow(record, fldname)

This method is triggered during the insertion (or a change) of a record. It returns the insertion date as a value of the dict with the key equal to record[fldname], where fldname is the name of the field inserted in the record.

Parameters:
  • record – the record
  • fldname – the field name
class gnr.app.gnrdbo.Table_counter

This table is automatically created for every package that inherit from GnrDboPackage.

config_db(pkg)

Configure the database, creating the database table and some columns

Parameters:pkg – the package object
counterCode(code, codekey, ymd)

Compose a counter code key and return it

Parameters:
  • code – the counter code
  • codekey – the formatting string for the key
  • ymd – a tuple including year, month and day as strings
createCounter(codekey, code, pkg, name, lastAssigned)

Create a counter. The counter is built through a Bag

Parameters:
  • codekey – the formatting string for the key
  • code – the counter code
  • pkg – the package object
  • name – the counter name
  • lastAssigned – TODO
formatCode(code, output, ymd, counter)

Create the output for the code and return it

Parameters:
  • code – the counter code
  • output – the formatting output for the key
  • ymd – a tuple including year, month and day as strings
  • counter – the long integer counter
getCounter(name, pkg, code, codekey='$YYYY_$MM_$K', output='$K/$YY$MM.$NNNN', date=None, phyear=False, lastAssigned=0)

Generate a new number from the specified counter and return it as a string

Parameters:
  • name – the counter name
  • pkg – the package object
  • code – the counter code
  • codekey – the formatting string for the key
  • output – the formatting output for the key
  • date – the the date of counter attribution
  • phyear – the fiscal year
  • lastAssigned – TODO
getLastCounterDate(name, pkg, code, codekey='$YYYY_$MM_$K', output='$K/$YY$MM.$NNNN', date=None, phyear=False, lastAssigned=0)

TODO

Parameters:
  • name – the counter name
  • pkg – the package object
  • code – the counter code
  • codekey – the formatting string for the key
  • output – the formatting output for the key
  • date – the the date of counter attribution
  • phyear – the fiscal year
  • lastAssigned – TODO
getYmd(date, phyear=False)

Return a tuple (year, month, date) of strings from a date.

Parameters:
  • date – the datetime
  • phyear – the fiscal year (not yet implemented)
setCounter(name, pkg, code, codekey='$YYYY_$MM_$K', output='$K/$YY$MM.$NNNN', date=None, phyear=False, value=0)

TODO

Parameters:
  • name – the counter name
  • pkg – the package object
  • code – the counter code
  • codekey – the codekey format (e.g. $YY for year)
  • output – the output format (e.g. $YY.$NNNN for year)
  • date – the current date
  • phyear – the fiscal year
  • value – TODO
use_dbstores()

TODO

class gnr.app.gnrdbo.Table_recordtag

TODO

config_db(pkg)

Configure the database, creating the database table and some columns

Parameters:pkg – the package object
setTagChildren(record_data, old_record_data=None)

TODO

Parameters:
  • record_data – TODO
  • old_record_data – TODO
trigger_onDeleting(record)

TODO

Parameters:record – TODO
trigger_onInserting(record_data)

TODO

Parameters:record_data – TODO
trigger_onUpdating(record_data, old_record)

TODO

Parameters:
  • record_data – TODO
  • old_record – TODO
use_dbstores()

TODO

TODO

TODO

Parameters:
  • table – the database table name, in the form packageName.tableName (packageName is the name of the package to which the table belongs to)
  • record_id – the record id
  • tag – TODO
  • value – TODO
config_db(pkg)

Configure the database, creating the database table and some columns

Parameters:pkg – the package object
getCountLinkDict(table, pkeys)

TODO

Parameters:
  • table – the database table name, in the form packageName.tableName (packageName is the name of the package to which the table belongs to)
  • pkeys – TODO
getTagDict(table)

TODO

Parameters:table – the database table name, in the form packageName.tableName (packageName is the name of the package to which the table belongs to)

TODO

Parameters:
  • table – the database table name, in the form packageName.tableName (packageName is the name of the package to which the table belongs to)
  • record_id – the record id
getTagLinksBag(table, record_id)

TODO

Parameters:
  • table – the database table name, in the form packageName.tableName (packageName is the name of the package to which the table belongs to)
  • record_id – the record id
getTagTable()

TODO

tagForeignKey(table)

TODO

Parameters:table – the database table name
use_dbstores()

TODO

class gnr.app.gnrdbo.Table_userobject

TODO

config_db(pkg)

Configure the database, creating the database table and some columns

Parameters:pkg – the package object
deleteUserObject(id, pkg=None)

TODO

Parameters:
  • id – TODO
  • pkg – the package object
listUserObject(objtype=None, pkg=None, tbl=None, userid=None, authtags=None, onlyQuicklist=None, flags=None)

TODO

Parameters:
  • objtype – TODO
  • pkg – the package object
  • tbl – the table object
  • userid – TODO
  • authtags – TODO
  • onlyQuicklist – TODO
  • flags – TODO
loadUserObject(id=None, objtype=None, **kwargs)

TODO

Parameters:
  • id – TODO
  • objtype – TODO
saveUserObject(data, id=None, code=None, objtype=None, pkg=None, tbl=None, userid=None, description=None, authtags=None, private=None, inside_shortlist=None, **kwargs)

TODO

Parameters:
  • data – TODO
  • id – TODO
  • code – TODO
  • objtype – TODO
  • pkg – the package object
  • tbl – the table object
  • userid – TODO
  • description – TODO
  • authtags – TODO
  • private – TODO
  • inside_shortlist – TODO
use_dbstores()

TODO