fillerbase Module
Classes to help fill widgets with data
Copyright (c) 2008-10 Christopher Perkins Original Version by Christopher Perkins 2008 Released under MIT license.
Bases: sprox.configbase.ConfigBase
Modifiers : |
---|
see sprox.configbase.
The base filler class.
Arguments : |
|
---|---|
Usage : |
>>> filler = FillerBase()
>>> filler.get_value()
{}
The main function for getting data to fill widgets,
Bases: sprox.fillerbase.FillerBase
This is the base class for generating table data for use in table widgets. The TableFiller uses it’s provider to obtain a dictionary of information about the __entity__ this Filler defines. This class is especially useful when you need to return a json stream, because it allows for customization of attributes. A package which has similar functionality to this is TurboJson, but TurboJson is rules-based, where the semantics for generating dictionaries follows the same sprox.configbase methodology.
Modifiers defined in this class
Name | Description | Default |
---|---|---|
__actions__ | An overridable function to define how to display action links in the form. | a function that creates an edit and delete link. |
__metadata_type__ | How should we get data from the provider. | FieldsMetadata |
__possible_field_names__ | See explanation below. | See below. |
see modifiers also in sprox.configbase.
Relations : |
---|
By default, TableFiller will populate relations (join or foreign_key) with either the value from the related table, or a comma-separated list of values. These values are derived from the related object given the field names provided by the __possible_field_names__ modifier. For instance, if you have a User class which is related to Groups, the groups item in the result dictionaries will be populated with Group.group_name. The default field names are: _name, name, description, title.
Restful Actions: | |
---|---|
By default, Table filler provides an “__actions__” item in the resultant dictionary list. This provides and edit, and (javascript) delete link which provide edit and DELETE functionality as HTML verbs in REST. For more information on developing RESTful URLs, please visit http://microformats.org/wiki/rest/urls .
Usage : |
---|
Here is how we would get the values to fill up a user’s table, minus the action column, and created date.
>>> class UsersFiller(TableFiller):
... __model__ = User
... __actions__ = False
... __omit_fields__ = ['created']
>>> users_filler = UsersFiller(session)
>>> value = users_filler.get_value(values={}, limit=20, offset=0)
>>> print value
[{'town': u'Arvada', 'user_id': u'1', 'user_name': u'asdf',
'town_id': u'1', 'groups': u'4', '_password': '******', 'password': '******',
'email_address': u'asdf@asdf.com', 'display_name': u'None'}]
Returns the total number of items possible for retrieval. This can only be executed after a get_value() call. This call is useful for creating pagination in the context of a user interface.
Get the values to fill a form widget.
Arguments : |
|
---|
Bases: sprox.fillerbase.FormFiller
This class will help to return a single record for use within a form or otherwise. The values are returned in dictionary form.
Modifiers : |
---|
see sprox.configbase.
Usage : |
---|
>>> class UserFiller(EditFormFiller):
... __model__ = User
>>> users_filler = UsersFiller(session)
>>> value = users_filler.get_value(values={'user_id':'1'})
>>> value
{'town': u'Arvada', 'user_id': u'1', 'created': u'2008-12-28 17:33:11.078931',
'user_name': u'asdf', 'town_id': u'1', 'groups': u'4', '_password': '******',
'password': '******', 'email_address': u'asdf@asdf.com', 'display_name': u'None'}
Bases: sprox.fillerbase.FillerBase
Bases: sprox.fillerbase.FormFiller
xxx: get the server/entity defaults.
Bases: sprox.fillerbase.FillerBase
The main function for getting data to fill widgets,
Bases: sprox.fillerbase.FillerBase
The main function for getting data to fill widgets,