17.1.1.8.1.2. cobra.util.context

17.1.1.8.1.2.1. Module Contents

17.1.1.8.1.2.1.1. Classes

HistoryManager

Record a list of actions to be taken at a later time. Used to

17.1.1.8.1.2.1.2. Functions

get_context(obj)

Search for a context manager

resettable(f)

A decorator to simplify the context management of simple object

class cobra.util.context.HistoryManager[source]

Bases: object

Record a list of actions to be taken at a later time. Used to implement context managers that allow temporary changes to a Model.

__call__(self, operation)[source]

Add the corresponding method to the history stack.

Parameters

operation (function) – A function to be called at a later time

reset(self)[source]

Trigger executions for all items in the stack in reverse order

cobra.util.context.get_context(obj)[source]

Search for a context manager

cobra.util.context.resettable(f)[source]

A decorator to simplify the context management of simple object attributes. Gets the value of the attribute prior to setting it, and stores a function to set the value to the old value in the HistoryManager.