Package bazaar :: Module motor :: Class Convertor
[show private | hide private]
[frames | no frames]

Type Convertor

object --+
         |
        Convertor


Relational and object data convertor.

The class creates all required SQL queries. It converts relational data to object oriented form and vice versa.

Motor class is used to connect and execute commands in database.
Method Summary
  __init__(self, cls, mtr, seqpattern)
Create data convertor object.
  add(self, obj)
Add object to database.
  addAscData(self, asc, pairs)
Add association relational data into database.
  createObject(self, data)
Create object from relational data.
  delAscData(self, asc, pairs)
Delete association relational data from database.
  delete(self, obj)
Delete object from database.
  dictToSQL(self, param)
Convert dictionary into WHERE SQL clause.
  find(self, query, param, field)
Find objects in database.
  get(self, key)
Load object from database.
  getAllAscData(self, asc)
Get all association data from database.
  getAscData(self, asc, obj)
Get association relational data for the application object.
  getData(self, obj)
Extract relational data from application object.
  getKey(self)
Create new primary key value with sequencer.
  getObjects(self)
Load objects from database.
  objToData(self, param)
Convert object oriented parameters to pure relational data.
  update(self, obj)
Update object in database.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Variable Summary
  cls: Application class, which objects are converted.
  columns: List of columns used with database queries.
  motor: Database access object.
  queries: Queries to modify data in database.

Method Details

__init__(self, cls, mtr, seqpattern=None)
(Constructor)

Create data convertor object.
Parameters:
cls - Application class.
mtr - Motor class object.
Overrides:
__builtin__.object.__init__

add(self, obj)

Add object to database.
Parameters:
obj - Object to add.

addAscData(self, asc, pairs)

Add association relational data into database.

Adding the data means adding data into link table of many to many association or updating appropriate column of one to many association.
Parameters:
asc - Association descriptor object.
pairs - List of association data - pairs of primary and foreign key values.

createObject(self, data)

Create object from relational data.
Parameters:
data - Relational data.
Returns:
Created object.

delAscData(self, asc, pairs)

Delete association relational data from database.

Deleting the data means removing data from link table of many to many association. In case of one to many association it means deleting rows of relation on "many" side or updating appropriate column of one to many association to None value (it depends on relationship configuration).
Parameters:
asc - Association descriptor object.
pairs - List of association data - pairs of primary and foreign key values.

delete(self, obj)

Delete object from database.
Parameters:
obj - Object to delete.

dictToSQL(self, param)

Convert dictionary into WHERE SQL clause.

All dictionary items are glued with AND operator.

See Also: bazaar.core.Bazaar.find

find(self, query, param=None, field=0)

Find objects in database.
Parameters:
query - SQL query or dictionary.
param - SQL query parameters.
field - SQL column number which describes found objects' primary key values.

See Also: bazaar.core.Bazaar.find

get(self, key)

Load object from database.
Parameters:
key - Primary key value of object to load.

getAllAscData(self, asc)

Get all association data from database.
Parameters:
asc - Association object.

getAscData(self, asc, obj)

Get association relational data for the application object.
Parameters:
asc - Association object.
obj - Application object.

getData(self, obj)

Extract relational data from application object.
Parameters:
obj - Application object.
Returns:
Dictionary of object's relational data.

getKey(self)

Create new primary key value with sequencer.
Returns:
New primary key value.

getObjects(self)

Load objects from database.

objToData(self, param)

Convert object oriented parameters to pure relational data.

See Also: bazaar.core.Bazaar.find

update(self, obj)

Update object in database.
Parameters:
obj - Object to update.

Instance Variable Details

cls

Application class, which objects are converted.

columns

List of columns used with database queries.

motor

Database access object.

queries

Queries to modify data in database.

Generated by Epydoc 2.1 on Tue May 10 18:27:29 2005 http://epydoc.sf.net