Welcome to django-observer documentation!

Contents:

observer package

Subpackages

observer.tests package

Subpackages
observer.tests.test_utils package
Submodules
observer.tests.test_utils.test_models module
observer.tests.test_utils.test_signals module
Module contents
observer.tests.test_watchers package
Submodules
observer.tests.test_watchers.test_base module
observer.tests.test_watchers.test_value module
Module contents
Submodules
observer.tests.compat module
observer.tests.factories module
observer.tests.models module
observer.tests.test_investigator module
Module contents

observer.utils package

Submodules
observer.utils.models module
observer.utils.signals module
observer.utils.signals.register_reciever(model, signal, receiver, sender=None, **kwargs)[source]

Connect signal and receiver of the model without duplication

Parameters:
  • model (class) – A target class
  • signal (signal) – A django signal
  • receiver (reciever) – A django signal receiver
  • sender (model) – A model class
  • **kwargs – Options passed to the signal.connect method
Returns:

True for new registration, False for already registered.

Return type:

bool

observer.utils.signals.unregister_reciever(model, signal, receiver)[source]

Disconnect signal and receiver of the model without exception

Parameters:
  • model (class) – A target class
  • signal (signal) – A django signal
  • receiver (reciever) – A django signal receiver
Returns:

True for success, False for already disconnected.

Return type:

bool

Module contents

observer.watchers package

Submodules
observer.watchers.auto module
observer.watchers.base module
observer.watchers.value module
Module contents

Submodules

observer.compat module

observer.compat.lru_cache(maxsize)[source]

observer.conf module

observer.decorators module

observer.decorators.watch(attr, callback, **kwargs)[source]

A decorator function for watching model attribute

observer.investigator module

class observer.investigator.Investigator(model, include=None, exclude=None)[source]

Bases: object

A model modification investigator

Create an instance of investigator with a model class and call ‘prepare’ method just before save the model. After the model is saved, call ‘investigate’ method and the method will yields the field names modified.

get_cached(pk, ignore_exception=True)[source]

Get cached object

Parameters:
  • pk (any) – A primary key of the object
  • ignore_exception (bool) – Return None if the object is not found, if this is False, ObjectDoesNotExist raised
Raises:

ObjectDoesNotExist – When a specified object does not exists in the cache and ignore_exception is False.

Returns:

object or None

get_object(pk, ignore_exception=True)[source]

Get latest object

It try to get the latest (unsaved) object from the database. If ignore_exception is True, return None, otherwise it raise ObjectDoesNotExist exception when no object is found.

Parameters:
  • pk (any) – A primary key of the object
  • ignore_exception (bool) – Return None if the object is not found. if this is False, ObjectDoesNotExist raised.
Raises:

ObjectDoesNotExist – When a specified object does not exists ignore_exception is False.

Returns:

object or None

investigate(instance)[source]

Call this function after the model instance is saved. It yield a name of modified attributes

prepare(instance)[source]

Call this function before save the model instance

observer.models module

observer.shortcuts module

observer.shortcuts.watch(model, attr, callback, **kwargs)[source]

A shortcut function for watching model attribute

Module contents

Indices and tables