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: - session (sqlalchemy.orm.session.Session) – current database session
- flush_context (sqlalchemy.orm.session.UOWTransaction) – internal SQLAlchemy object
- instances – deprecated
-
biweeklybudget.db_event_handlers.handle_budget_trans_amount_change(**kwargs)[source]¶ Handle change of
BudgetTransaction.amountfor existing instances (trans_idis not None). For new or deleted instances, we rely onhandle_new_or_deleted_budget_transaction()called viahandle_before_flush().If the BudgetTransaction’s
budgetuses aBudgetwithis_periodicFalse(i.e. a standing budget), update the Budget’scurrent_balancefor 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_flushevent 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 onhandle_budget_trans_amount_change().If the BudgetTransaction’s
budgetis aBudgetwithis_periodicFalse(i.e. a standing budget), update the Budget’scurrent_balancefor this transaction.Parameters: session (sqlalchemy.orm.session.Session) – current database session
-
biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change(session)[source]¶ before_flushevent handler (sqlalchemy.orm.events.SessionEvents.before_flush()) on the DB session, to handle setting theis_*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: - db_session (sqlalchemy.orm.scoping.scoped_session) – the Database Session
- engine (sqlalchemy.engine.Engine) – top-level Database Engine instance
-
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_executeevent.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_executeevent.For information, see: http://docs.sqlalchemy.org/en/latest/faq/performance.html#query-profiling