ZODB.Architecture.DB
Documentation
DB objects model object databases. An object database is responsible for managing connections and associating Connections with Storage objects.
Concurrency
guarded
Persistence
transient
Using DB objects
DB usage is quite simple. An application creates an DB object, typically during application initialization. When an application thread needs to access object data, it gets a connection, using the DB open method. When a thread is done using database objects, it closes the connection. It is extremely important for the thread to close the connection when it is done with it to prevent connection �leakage�. If a connection is to be used for a single transaction, then the application may supply the transaction to the open call. In this case, the connection is automatically closed at the end of the transaction. Figure 2 provides a simple example of an application that creates multiple threads that each use a separate connection to a database.
def thread_activity(connection):
get_transaction().begin(user=�jim�)
myobject=connection.getRoot(�myobject�)
....do interesting things with myobject...
get_transaction().commit()
connection.close()
db=ZODB.DB(ZODB.FileStorage('data.bbb'))
thread.start_new_thread(thread_activity,(db.open(),))
thread.start_new_thread(thread_activity,(db.open(),))