cowbird.database
Database package for pyramid.
Add the database in the pyramid registry and a property db for the requests.
Package Contents
Classes
Return the unique identifier of db type matching settings. |
Functions
|
Retrieves the application |
|
Retrieve application settings from a supported container. |
|
Obtains the database connection from configured application settings. |
|
Attributes
-
class
cowbird.database.
MongoDatabase
(container)[source] Bases:
cowbird.database.base.DatabaseInterface
Return the unique identifier of db type matching settings.
Initialize the mongo database from various type of container.
-
_database
-
_settings
-
_stores
-
type
= mongodb
-
reset_store
(self, store_type)
-
get_store
(self: Union[str, Type[cowbird.database.stores.StoreInterface], AnyMongodbStoreType], store_type: Any, *store_args: Any, **store_kwargs) → AnyMongodbStore Retrieve a store from the database.
- Parameters
store_type – type of the store to retrieve/create.
store_args – additional arguments to pass down to the store.
store_kwargs – additional keyword arguments to pass down to the store.
-
get_session
(self: Ellipsis) → Any
-
get_information
(self: Ellipsis) → cowbird.typedefs.JSON - Returns
{‘version’: version, ‘type’: db_type}
-
is_ready
(self: Ellipsis) → bool
-
-
cowbird.database.
get_registry
(container: cowbird.typedefs.AnyRegistryContainer, nothrow: bool = False) → Optional[pyramid.registry.Registry][source] Retrieves the application
registry
from various containers referencing to it.
-
cowbird.database.
get_settings
(container: Optional[cowbird.typedefs.AnySettingsContainer], app: bool = False) → cowbird.typedefs.SettingsType[source] Retrieve application settings from a supported container.
- Parameters
container – supported container with an handle to application settings.
app – allow retrieving from current thread registry if no container was defined.
- Returns
found application settings dictionary.
- Raises
TypeError – when no application settings could be found or unsupported container.
-
cowbird.database.
get_db
(container: cowbird.typedefs.AnySettingsContainer, reset_connection: bool = False) → mongodb.MongoDatabase[source] Obtains the database connection from configured application settings.
If
reset_connection
isTrue
, thecontainer
must be the applicationRegistry
or any container that can retrieve it to accomplish reference reset. Otherwise, any settings container can be provided.