relstorage.adapters.connmanager#

class AbstractConnectionManager(options, driver)[source]#

Bases: object

Abstract base class for connection management.

Responsible for opening and closing database connections.

Parameters:
add_on_load_opened(f)[source]#

Add a callable (cursor, restart=bool) for when a load connection is opened.

Hooks are called in the order added.

New in version 2.1a1.

add_on_store_opened(f)[source]#

Add a callable(cursor, restart=bool) for when a store connection is opened.

Hooks are called in the order added.

New in version 2.1a1.

check_replica(conn, cursor, replica_selector=None)[source]#

Raise an exception if the connection belongs to an old replica

close(conn=None, cursor=None)[source]#

Close a connection and cursor, ignoring certain errors.

Return a True value if the connection was closed cleanly. Return a False value if the processes ignored an error.

open(isolation=None, read_only=False, deferrable=False, replica_selector=None, application_name=None, **kwargs)[source]#

Open a database connection and return (conn, cursor).

open_and_call(callback)[source]#

Call callback(connection, cursor) with a newly open connection and cursor.

If the function returns, commits the transaction and returns the result returned by the function. If the function raises an exception, aborts the transaction then propagates the exception.

open_for_pre_pack()[source]#

Open a connection to be used for the pre-pack phase. Returns (conn, cursor).

open_for_store(**open_args)[source]#

Open and initialize a connection for storing objects.

Returns (conn, cursor).

restart_load(conn, cursor, needs_rollback=True)[source]#

Reinitialize a connection for loading objects.

restart_store(conn, cursor, needs_rollback=True)[source]#

Reuse a store connection.

set_on_store_opened(f)#

Add a callable(cursor, restart=bool) for when a store connection is opened.

Hooks are called in the order added.

New in version 2.1a1.

connection_callback(isolation_level=None, read_only=None, deferrable=None, application_name=None, inherit=None)[source]#

Decorator for functions used in IConnectionManager.open_and_call().

When the function is called, it will be given a connection that has the given traits.

Use inherit=BaseClass.func when you’re overriding a callback function func.