| Home | Trees | Index | Help |
|
|---|
| Package bazaar :: Module core :: Class Bazaar |
|
See Also: Broker bazaar.motor.Motor
| Method Summary | |
|---|---|
Start the Bazaar layer. | |
Add object to database. | |
Close database connection. | |
Commit pending database transactions. | |
Make new database connection. | |
Delete object from database. | |
Find objects of given class in database. | |
Get list of application objects. | |
Initialize the Bazaar layer. | |
Parse Bazaar configuration. | |
Reload objects from database. | |
Rollback database transactions. | |
Set Bazaar configuration. | |
Update object in database. | |
| Instance Variable Summary | |
|---|---|
brokers: Dictionary of brokers. | |
cls_list: List of application classes. | |
dbmod: Python DB API module. | |
dsn: Python DB API database source name. | |
motor: Database access object. | |
| Method Details |
|---|
__init__(self,
cls_list,
config=None,
dsn='',
dbmod=None,
seqpattern=None)
|
add(self, obj)Add object to database.
|
closeDBConn(self)Close database connection.
|
commit(self)Commit pending database transactions. |
connectDB(self, dsn=None)Make new database connection. New database connection is created with specified database source name, which must conform to Python DB API Specification, i.e.:
bazaar.connectDB('dbname=addressbook host=localhost port=5432 user=bird')
It is possible to reconnect with previous database source name,
too:
bazaar.connectDB()
|
delete(self, obj)Delete object from database. Object's primary key value is set toNone.
|
find(self, cls, query, param=None, field=0)Find objects of given class in database. The method can be used in two ways. First, simple dictionary can be passed as query:
# iterator is returned, so its next() method is used to get
# the object
apple = bazaar.find(Article, {'name': 'apple'}).next()
Dictionary can contain objects as values, i.e.:
bazaar.find(OrderItem, {'article': art})
Second, it is possible to use full power of SQL language:
# find orders and their articles if order amount is greater
# than 50$
# find orders with the query
query = """
select O.__key__ from "order" O
left outer join order_item OI on O.__key__ = OI.order_fkey
left outer join article A on OI.article_fkey = A.__key__
group by O.__key__ having sum(A.price) > 50
"""
for ord in bzr.find(Order, query):
print ord # show order
for oi in ord.items: # show order's articles
print oi.article
|
getObjects(self, cls)Get list of application objects. Only objects of specified class are returned.
|
init(self)Initialize the Bazaar layer. |
parseConfig(self, config)Parse Bazaar configuration.
|
reloadObjects(self, cls, now=False)Reload objects from database. If objects immediate reload is requested, then method returns iterator of objects being loaded from database.
|
rollback(self)Rollback database transactions. |
setConfig(self, config)Set Bazaar configuration. |
update(self, obj)Update object in database.
|
| Instance Variable Details |
|---|
brokersDictionary of brokers. Brokers are mapped with its class application. |
cls_listList of application classes. |
dbmodPython DB API module. |
dsnPython DB API database source name. |
motorDatabase access object. |
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.0 on Sun May 23 19:11:17 2004 | http://epydoc.sf.net |