biweeklybudget.db_event_handlers module

biweeklybudget.db_event_handlers.handle_account_re_change(session)[source]

Handler for change of one of:

When one of these regexes is changed on an Account, we trigger a re-run of update_is_fields() on all OFXTransactions for the account.

Parameters:session (sqlalchemy.orm.session.Session) – current database session
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_budget_trans_amount_change(**kwargs)[source]

Handle change of BudgetTransaction.amount for existing instances (trans_id is not None). For new or deleted instances, we rely on handle_new_or_deleted_budget_transaction() called via handle_before_flush().

If the BudgetTransaction’s budget uses 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.handle_new_or_deleted_budget_transaction(session)[source]

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

If the BudgetTransaction’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_ofx_transaction_new_or_change(session)[source]

before_flush event handler (sqlalchemy.orm.events.SessionEvents.before_flush()) on the DB session, to handle setting the is_* fields on new or changed OFXTransaction instances according to its Account.

Parameters:session (sqlalchemy.orm.session.Session) – current database session
biweeklybudget.db_event_handlers.init_event_listeners(db_session, engine)[source]

Initialize/register all SQLAlchemy event listeners.

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

Parameters:
biweeklybudget.db_event_handlers.query_profile_after(conn, cursor, statement, parameters, context, _)[source]

Query profiling database event listener, to be added as listener on the Engine’s after_cursor_execute event.

For information, see: http://docs.sqlalchemy.org/en/latest/faq/performance.html#query-profiling

biweeklybudget.db_event_handlers.query_profile_before(conn, cursor, statement, parameters, context, _)[source]

Query profiling database event listener, to be added as listener on the Engine’s before_cursor_execute event.

For information, see: http://docs.sqlalchemy.org/en/latest/faq/performance.html#query-profiling