passerine.db.manager

Note

This page is automatically generated. If you don’t see anything, this means this sub-module is not meant to be used. If you really want to know what it is, please check out the source code at passerine/db/manager.py.

class passerine.db.manager.Manager(driver)

Entity Manager

This is to manage the unit-of-work session.

Parameters:driver (passerine.db.driver.interface.DriverInterface) – the driver interface
close_session(id)

Close the managed session

Warning

This method is designed to bypass errors when the given ID is unavailable or already closed.

driver

Driver API

Return type:passerine.db.driver.interface.DriverInterface
get_repository(ref_class, session_id=None)

Retrieve the repository.

Parameters:
  • ref_class (type) – The reference class
  • session_id – The supervised session ID
Return type:

passerine.db.repository.Repository

Note

This is designed for Imagination’s factorization.

Note

With an unsupervised session, the memory usage may be higher than usual as the memory reference may not be freed as long as the reference to the returned repository continues to exist in active threads.

open_session(id=None, supervised=False)

Open a session

Parameters:
  • id – the session ID
  • supervised (bool) – the flag to indicate that the opening session will be observed and supervised by the manager. This allows the session to be reused by multiple components. However, it is not thread-safe. It is disabled by default.
session(*args, **kwds)

Open a session in the context manager.

Parameters:
  • id – the session ID
  • supervised (bool) – the flag to indicate that the opening session will be observed and supervised by the manager. This allows the session to be reused by multiple components. However, it is not thread-safe. It is disabled by default.

Note

The end of the context will close the open session.

class passerine.db.manager.ManagerFactory(urls=None, protocols=None)

Manager Factory

Parameters:
  • urls (dict) – the alias-to-endpoint-URL map
  • protocols (dict) – the protocol-to-fully-qualified-module-path map
get(alias)

Retrieve the database by the manager alias.

Parameters:alias (str) – the alias of the manager.
Return type:passerine.db.manager.Manager
register(protocol, driver_class)

Register the protocol to the driver class.

Parameters:
set(alias, url)

Define the database endpoint URL to a manager (identified by the given alias).

Parameters:
  • alias (str) – the alias of the manager.
  • url (str) – the URL to the endpoint