iprovider Module
This contains the class which allows sprox to interface with any database via an object-relational mapper (ORM) or object-document mapper (ODM).
Definitions:
- Mapped object
- An object which is implemented by the ORM/ODM and represents a record or document in the database.
- Entity
- An object that represents a set of mapped objects that are part of the same collection or table in the database.
- Field
- A definition of aproperty of a mapped object which is accessible using attribute notation. An entity contains a set of fields, and each field has unique name within the entity.
- Property field
- A field which contains a value which is presentable to the user.
- Foreign key field
- A field which contains a value that refers to another object in the database, and which is hidden from the user.
- Relation field
- A field whose value is another mapped object in the database, or a list or set of such objects. The referened objects are presented to the user using a selection or prompting widget.
- Primary key field
- A set of fields which identify the mapped object within the entity. Need not be user-presentable.
- Dictify
- An alternative representation of a mapped object as a dictionary; see the dictify method docstring for details.
Copyright © 2008 Christopher Perkins Original Version by Christopher Perkins 2008 Released under MIT license.
Create an entry of type entity with the given params.
Delete an entry of typeentity which matches the params.
Return a dictionary with keys being the names of fields in te object and values being the values of those fields, except that values that are mapped objects are replaced with the value of the corresponding primary key of the related object instead of the actual mapped object.
Arguments : |
|
---|---|
Returns : |
A dictionary of {field_name: value} where field_name is the name of a property field or relation field, and value is the value of the property field or the related primary key value.
Get a single dictify of type entity which matches the params.
Equivalent to dictify(get(entity, params), fields, omit_fields).
Get the default values for form filling based on the database schema.
Get all dropdown options for a given entity field.
Arguments : |
|
---|---|
Returns : |
A list of tuples with (id, view_value) as items.
Get all entities available for this provider.
Get an entity with the given name.
Get a field with the given field name.
Return a dict with any additional arguments that should be passed for the widget for the field in the entity.
Returns : |
---|
A dict of additional widget arguments.
Get all of the fields for a given entity, excluding foreign key fields.
Arguments : |
|
---|---|
Returns : |
A list of names of the fields that are not foreign keys in the entity.
Get a single mapped object of type entity which matches the params.
Get the single primary field for an entity. A single primary field is required for EditableForm and AddRecordForm-based forms.
Returns : |
---|
A field which unique identifies a record. Raises an exception if there is no such field.
Get the fields in the entity which uniquely identifies a record.
Returns : |
---|
A sequence of fields which when taken together uniquely identify a record.
Get all of the field names in an enity which are relation fields.
Returns : |
---|
A list of names of relation fields in the entity.
Get the name of the field which first matches the possible colums
Arguments : |
|
---|
Determine if the field in the entity is a binary field.
Determine if a field is nullable.
Determine if a field is a relation field.
Return true if the value for field is not yet used within the entity.
Return true if the field within the entity is a primary or alternate key.
Perform a query against this entity.
Arguments : |
|
---|---|
Returns : |
A tuple (count, iter) where iter is an iterator of mapped objects.
For the relation field with the given name, return the corresponding foreign key field(s) in the entity.
Returns : |
---|
A list of the names of the foreign key fields.
Update an entry of type entity which matches the params.