Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-observer

How to install django-observer

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-observer
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.4.1
0.4.2Never BuiltWhy not?
0.4.1 Available View build log
0.3rc5 Available View build log
0.3rc4 Available View build log
0.2rc1 Available View build log
0.1 Failed View build log
Windows (64-bit)
0.4.1
0.4.2Never BuiltWhy not?
0.4.1 Available View build log
0.3rc5 Available View build log
0.3rc4 Available View build log
0.2rc1 Available View build log
0.1 Failed View build log
Mac OS X (10.5+)
0.4.1
0.4.2Never BuiltWhy not?
0.4.1 Available View build log
0.3rc5 Available View build log
0.3rc4 Available View build log
0.2rc1 Available View build log
0.1 Failed View build log
Linux (32-bit)
0.4.1
0.4.2Never BuiltWhy not?
0.4.1 Available View build log
0.3rc5 Available View build log
0.3rc4 Available View build log
0.2rc1 Available View build log
0.1 Failed View build log
Linux (64-bit)
0.4.1
0.4.2 Failed View build log
0.4.1 Available View build log
0.3rc5 Available View build log
0.3rc4 Available View build log
0.2rc1 Available View build log
0.1 Failed View build log
 
Author
License
MIT
Lastest release
version 0.4.2 on Jan 9th, 2014

Watch modification of any type of field in Django's model and call registered callback function

This observer can watch

  • Any value type of field (CharField, IntegerField ...)
  • Any Model type of field (ForeignKey, OneToOneField, GenericForeignKey)
  • Any RelatedManager type of field (field automatically created via related_name of ForeignKey)
  • Any ManyRelatedManager type of field (ManyToManyField)
  • Any GenericRelatedObjectManager type of field (GenericRelation)
  • Any Model instance

Install

This library is on PyPI so you can install it with:

pip install django-observer

or from github:

pip install git+https://github.com/lambdalisue/django-observer.git

Usage

>>> from django.db import models
>>> from observer import watch
>>>
>>> class Entry(models.Model):
...     status = models.CharFiled('status', max_length=10)
...     body = models.CharField('title', max_length=100)
...
...     def save(self, *args, **kwargs):
...         super(Entry, self).save(*args, **kwargs)
...
...         # Watch callback, this is automatically called if `status` is **changed**
...         def watch_callback(sender, obj, attr):
...             # sender is a watcher instance
...             # obj is a instance of target
...             # attr is a name of target field
...             if obj.status == 'draft':
...                 obj.title = "draft - %s" % obj.body
...             else:
...                 obj.title = "publish - %s" % obj.body
...         # Start watching
...         self._watcher = watch(self, 'status', watch_callback)

See observer_test/src/miniblog/blog/tests/test_observer.py for more detail.

Settings

OBSERVER_DEFAULT_WATCHER
A class of watcher. Default is 'observer.watcher.complex.ComplexWatcher'

Subscribe to package updates

Last updated Jan 9th, 2014

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.