biweeklybudget.db_event_handlers module

biweeklybudget.db_event_handlers.handle_before_flush(session, flush_context, instances)[source]

Hook into before_flush (sqlalchemy.orm.events.SessionEvents.before_flush()) on the DB session, to handle updates that need to be made before persisting data. Currently, this method just calls a number of other methods to handle specific cases:

Parameters:
biweeklybudget.db_event_handlers.handle_new_transaction(session)[source]

before_flush event handler (sqlalchemy.orm.events.SessionEvents.before_flush()) on the DB session, to handle creation of new Transactions. For updates to existing Transactions, we rely on handle_trans_amount_change().

If the Transaction’s budget is a Budget with is_periodic False (i.e. a standing budget), update the Budget’s current_balance for this transaction.

Parameters:session (sqlalchemy.orm.session.Session) – current database session
biweeklybudget.db_event_handlers.handle_trans_amount_change(**kwargs)[source]

Handle change of Transaction.actual_amount for existing instances (id is not None). For new instances, we rely on handle_new_transaction() called via handle_before_flush().

If the Transaction’s budget is a Budget with is_periodic False (i.e. a standing budget), update the Budget’s current_balance for this transaction.

See: sqlalchemy.orm.events.AttributeEvents.set()

Parameters:kwargs (dict) – keyword arguments
biweeklybudget.db_event_handlers.init_event_listeners(db_session)[source]

Initialize/register all SQLAlchemy event listeners.

See http://docs.sqlalchemy.org/en/latest/orm/events.html

Parameters:db_session (sqlalchemy.orm.session.Session) – the Database Session