Base data manager. This is just an abstract class of definitions to be implemented by the real data managers.
Class DataManager( name, location )
Methods | |
addEntity | Puts an entity in the data manager. |
configure | Configure this data manager. |
count | Count records from an entity. |
create | Create the database. |
createDB | Creates the physical underlying DatabaseResource. |
createEntity | Creates an entity in the database. Called back by DataManager.create. |
delete | Modifies the values of an entity in the database. |
entity | Loads an entity definition. |
insert | Inserts a new item in the data pool. |
query | Query multiple records from an entity. |
queryItem | Query an entity -- for a single item. |
update | Modifies the values of an entity in the database. |
Puts an entity in the data manager.
addEntity( Entity, entity )
Entity | an instance to be added. |
Configure this data manager.
configure( vars )
vars | an array of variables to be configured. | ||
Raise |
|
The subclasses must override this mehtod.
Count records from an entity.
count( entity, view )
entity | The entity to be queried. |
view | A field list or DBView eventually filtering this count |
The subclasses must override this mehtod.
Create the database.
create( cond )
cond | True if the database should be created only if not found (conditional), false to re-create it. |
This performs a self.createDB( cond ) call right after loading all the entities, and then invokes create() onthe entities in the right order.
So, the upstream DB manager should be re-implementing the createDB method to create a new empty DB.
Creates the physical underlying DatabaseResource.
createDB( cond )
cond | if true should create the database only if not alredy existing. |
The subclasses must override this mehtod.
Creates an entity in the database. Called back by DataManager.create.
createEntity( entity, cond )
entity | The DBEntity to be created in the database. |
cond | True to create only if the entity doesn't exist. |
Modifies the values of an entity in the database.
delete( entity, data, eid )
entity | The entity to be added. |
data | A dictionary of data to be stored. |
Return | The new entity ID. |
The subclasses must override this mehtod.
Loads an entity definition.
entity( ename )
ename | The name of the entity to be loaded. |
Inserts a new item in the data pool.
insert( entity, data )
entity | The entity to be added. |
data | A dictionary of data to be stored. |
Return | The new entity ID. |
The subclasses must override this mehtod.
Query multiple records from an entity.
query( entity, view, start, count )
entity | The entity to be queried. |
view | A field list or DBView configuring this query (nil for all). |
start | Start after N fetched records (nil for 0). |
count | Get N records in the returned data (nil for all). |
Return | An array of DBRecord entity containing the retreived data. |
The view parameter can be an array of field names that should be retrieved from this entity, or a View that will select just part of the elements.
The subclasses must override this mehtod.
Query an entity -- for a single item.
queryItem( entity, key_fields, view )
entity | The entity to be queried. |
key_fields | The ID of the entity to retreive. |
view | A view shaping the fields to be retreived (or nil) |
Return | A DBRecord entity containing the retreived data. |
The subclasses must override this mehtod.
Modifies the values of an entity in the database.
update( entity, data, eid )
entity | The entity to be added. |
data | A dictionary of data to be stored. |
Return | The new entity ID. |
The subclasses must override this mehtod.