grate.atomic

grate.atomic.atomic(f)

Transforms the given function into an atomic operation. The function itself should be idempotent, that is repeatable without harm.

>>> class Foo(mongoengine.Document):
...     @atomic
...     def bar(self):
...         # Do shit.
...         return "stuff"
class grate.atomic.ReferenceMapping

A mongoengine.Document that maps names to values which are mongoengine.Documents.

key

The key (a string).

value

The reference.

class grate.atomic.OperationLog(**values)

A log of a operation. This stores information about a method call on mongoengine.Documents.

arg_others

A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.

New in version 0.3.

arg_references

A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.

classmethod create(op)
Parameters:op – The Operation instance.
Returns:A OperationLog from the given Operation.
classmethod from_args(args)
Parameters:args – The list of arguments passed to the function.
Returns:A tuple of a list of ReferenceMappings and the other arguments.
classmethod from_kwargs(kwargs)
Parameters:kwargs – A dict.
Returns:A tuple of a list of ReferenceMappings and the other arguments.
id

An field wrapper around MongoDB’s ObjectIds.

instance

A reference to any Document subclass that will be automatically dereferenced on access (lazily).

New in version 0.3.

kwarg_others

A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.

New in version 0.3.

kwarg_references

A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.

method

A unicode string field.

recover()

Recovers the log.

classmethod recover_all()

Runs recovery on all interrupted operations.

timestamp

A datetime field.

to_args()
Returns:The original list or arguments.
to_kwargs()
Returns:The original dict of keyword arguments.
class grate.atomic.Operation

This provides a context manager (the with syntax).

__init__(instance, method, *args, **kwargs)
__enter__()
__exit__(type, value, traceback)

Previous topic

grate.access

Next topic

grate.djangocompat

This Page