sprox.fillerbase

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.

Classes

class sprox.fillerbase.FillerBase(provider_hint=None, **provider_hints)

Bases: sprox.configbase.ConfigBase

Modifiers :

see sprox.configbase.

The base filler class.

Arguments :
values

pass through of values. This is typically a set of default values that is updated by the filler. This is useful when updating an existing form.

kw

Set of keyword arguments for assisting the fill. This is for instance information like offset and limit for a TableFiller.

Usage :
>>> filler = FillerBase()
>>> filler.get_value()
{}
get_value(values=None, **kw)

The main function for getting data to fill widgets,

class sprox.fillerbase.TableFiller(provider_hint=None, **provider_hints)

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'}]
get_count()

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_value(values=None, **kw)

Get the values to fill a form widget.

Arguments :
offset

offset into the records

limit

number of records to return

order_by

name of the column to the return values ordered by

desc

order the columns in descending order

class sprox.fillerbase.EditFormFiller(provider_hint=None, **provider_hints)

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'}
get_value(values=None, **kw)
class sprox.fillerbase.FormFiller(provider_hint=None, **provider_hints)

Bases: sprox.fillerbase.FillerBase

get_value(values=None, **kw)
class sprox.fillerbase.AddFormFiller(provider_hint=None, **provider_hints)

Bases: sprox.fillerbase.FormFiller

get_value(values=None, **kw)

xxx: get the server/entity defaults.

class sprox.fillerbase.ModelDefFiller(provider_hint=None, **provider_hints)

Bases: sprox.fillerbase.FillerBase

get_value(values=None, **kw)

The main function for getting data to fill widgets,

class sprox.fillerbase.ModelsFiller(provider_hint=None, **provider_hints)

Bases: sprox.fillerbase.FillerBase

get_value(values=None, **kw)

The main function for getting data to fill widgets,

Discuss

blog comments powered by Disqus

Table Of Contents

Previous topic

sprox.tablebase

Next topic

sprox.configbase

This Page