Transaction helpers¶
chamber.utils.transaction.atomic¶
-
atomic()¶ Like django
transaction.atomic()decorator chamber atomic can be used for surrounding method, function or block of code with db atomic block. But because we often uses reversion the atomic is surrounded withcreate_revisiondecorator
-
transaction_signals()¶ Decorator that is used for automatic invoking on success signals. Function or handler registered with
on_successfunction is executed if block of code will not thrown exception. Its behaviour is very similar to atomic block, if you will inherit these decorators the event will be invoked until after the completion of last decorated code.
-
atomic_with_signals()¶ Combination of
atomicandtransaction_signals.
-
on_success()¶ Function for on success handlers registration. If thransaction signals are not activated (decorator
transaction_signalsis not used) the handler will be invoked immediately.
chamber.utils.transaction.OnSuccessHandler¶
Handler that can be used for implementation tasks that should be called only after successful pass throught code. Hanlder is automatically registered inside its constructior.
chamber.utils.transaction.OneTimeOnSuccessHandler¶
One time handler is registered and called only once. But all input parameters are stored inside list of kwargs.
-
class
chamber.utils.transaction.OneTimeOnSuccessHandler¶ -
handle(**kwargs_list)¶ There should be implemented code that will be invoked after success pass though the code. Difference from
OnSuccessHandler.handleis that kwargs is stored inside list in the order how handlers was created
-
_get_unique_id()¶ The uniqueness of the handler must be somehow defined. You must implement this method to define unique identifier of the handler. By default it is identified with has of the class
-
chamber.utils.transaction.InstanceOneTimeOnSuccessHandler¶
Special type of unique handler that is identified with iteslf and model instance of the input model object.