wutta_continuum.conf

App Configuration

class wutta_continuum.conf.WuttaContinuumConfigExtension[source]

App config extension for Wutta-Continuum.

This adds a startup hook, which can optionally turn on the SQLAlchemy-Continuum versioning features for the main app DB.

startup(config)[source]

Perform final configuration setup for app startup.

This will do nothing at all, unless config enables the versioning feature. This must be done in config file and not in DB settings table:

[wutta_continuum]
enable_versioning = true

Once enabled, this method will configure the integration, via these steps:

  1. call sqlalchemy_continuum.make_versioned()

  2. call wuttjamaican.app.AppHandler.get_model()

  3. call sqlalchemy.orm.configure_mappers()

For more about SQLAlchemy-Continuum see Introduction.

Two plugins are provided to make_versioned():

The first is TransactionMetaPlugin for sake of adding comments (see transaction_meta).

The second by default is WuttaContinuumPlugin but you can override with config:

[wutta_continuum]
wutta_plugin_spec = poser.db.continuum:PoserContinuumPlugin

See also the SQLAlchemy-Continuum docs for Plugins.

class wutta_continuum.conf.WuttaContinuumPlugin[source]

SQLAlchemy-Continuum manager plugin for Wutta-Continuum.

This is the default plugin used within startup() unless config overrides.

This tries to establish the user and IP address responsible, and comment if applicable, for the current transaction.

See also the SQLAlchemy-Continuum docs for Plugins.

before_flush(uow, session)[source]

We use this hook to inject the “comment” for current transaction, if applicable.

This checks the session for the comment; so any session can specify one like so:

session.info["continuum_comment"] = "hello world"
get_remote_addr(uow, session)[source]

This should return the effective IP address responsible for the current change(s).

Default logic will assume the “current machine” e.g. where a CLI command or script is running. In practice that often means this winds up being 127.0.0.1 or similar.

Returns:

IP address (v4 or v6) as string

get_user_id(uow, session)[source]

This should return the effective User.uuid indicating who is responsible for the current change(s).

Default logic does not have a way to determine current user on its own per se. However it can inspect the session, and use a value from there if found.

Any session can therefore declare the resonsible user:

myuser = session.query(model.User).first()
session.info["continuum_user_id"] = myuser.uuid
Returns:

wuttjamaican.db.model.auth.User.uuid value, or None

transaction_args(uow, session)[source]

This is a standard hook method for SQLAchemy-Continuum plugins. We use it to (try to) inject these values, which then become set on the current (new) transaction: