pyramid_zodbconn API

pyramid_zodbconn.includeme(config, db_from_uri=<function db_from_uri>, open=<built-in function open>)

This includeme recognizes a zodbconn.uri setting in your deployment settings and creates a ZODB database if it finds one. zodbconn.uri is the database URI or URIs (either a whitespace-delimited string, a carriage-return-delimed string or a list of strings).

Database is activated with ZODB.ActivityMonitor.ActivityMonitor.

It will also recognize named database URIs as long as an unnamed database is in the configuration too:

zodbconn.uri.sessions = file:///home/project/var/Data.fs

Use the key zodbconn.transferlog in the deployment settings to specify a filename to write ZODB load/store information to, or leave key’s value blank to send to stdout.

pyramid_zodbconn.get_connection(request, dbname=None)

request must be a Pyramid request object.

When called with no dbname argument or a dbname argument of None, return a connection to the primary datbase (the database set up as zodbconn.uri in the current configuration).

If you’re using named databases, you can obtain a connection to a named database by passing its name as dbname. It must be the name of a database (e.g. if you’ve added to the configuration, it should be foo).

Connection Events

All connection events have two attributes: conn and request. conn is the ZODB connection related to the event, request is the request which caused the event.

class pyramid_zodbconn.ZODBConnectionOpened(conn, request)

An event sent when a ZODB connection is opened

class pyramid_zodbconn.ZODBConnectionWillClose(conn, request)

An event sent when a ZODB connection is about to be closed

class pyramid_zodbconn.ZODBConnectionClosed(conn, request)

An event sent when a ZODB connection is about to be closed