Package wsgitools :: Module digest :: Class LazyDBAPI2Opener
[hide private]
[frames] | no frames]

Class LazyDBAPI2Opener

source code


Connects to database on first request. Otherwise it behaves like a dbapi2 connection. This may be usefull in combination with scgi.forkpool, because this way each worker child opens a new database connection when the first request is to be answered.

Instance Methods [hide private]
 
__init__(self, function, *args, **kwargs)
The database will be connected on the first method call.
source code
 
_getdbhandle(self)
Returns an open database connection.
source code
 
cursor(self)
dbapi2
source code
 
commit(self)
dbapi2
source code
 
rollback(self)
dbapi2
source code
 
close(self)
dbapi2
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, function, *args, **kwargs)
(Constructor)

source code 

The database will be connected on the first method call. This is done by calling the given function with the remaining parameters.

Parameters:
  • function - is the function that connects to the database
Overrides: object.__init__

_getdbhandle(self)

source code 

Returns an open database connection. Open if necessary.