=== modified file 'django/db/models/signals.py'
|
|
|
1 | | class_prepared = object() |
2 | | |
3 | | pre_init= object() |
4 | | post_init = object() |
5 | | |
6 | | pre_save = object() |
7 | | post_save = object() |
8 | | |
9 | | pre_delete = object() |
10 | | post_delete = object() |
11 | | |
12 | | post_syncdb = object() |
| 1 | from django.dispatch import signal |
| 2 | |
| 3 | class_prepared = signal("class_prepared") |
| 4 | |
| 5 | pre_init= signal('pre_init') |
| 6 | post_init = signal('post_init') |
| 7 | |
| 8 | pre_save = signal('pre_save') |
| 9 | post_save = signal('post_save') |
| 10 | |
| 11 | pre_delete = signal('pre_delete') |
| 12 | post_delete = signal('post_delete') |
| 13 | |
| 14 | post_syncdb = signal('post_syncdb') |
=== modified file 'django/dispatch/__init__.py'
|
|
|
4 | 4 | __author__ = "Patrick K. O'Brien" |
5 | 5 | __license__ = "BSD-style, see license.txt for details" |
6 | 6 | |
| 7 | class _signal(object): |
| 8 | def __init__(self, label): |
| 9 | self.label = label |
| 10 | |
| 11 | def __str__(self): |
| 12 | return self.label |
| 13 | |
| 14 | def __repr__(self): |
| 15 | return "<signal signal=%r @#%x>" % (self.label, id(self)) |
| 16 | |
| 17 | def signal(signal_name, docstring=None): |
| 18 | if docstring is None: |
| 19 | return _signal(signal_name) |
| 20 | class signal(_signal): |
| 21 | __doc__ = docstring |
| 22 | return signal(signal_name) |
=== modified file 'django/dispatch/dispatcher.py'
|
|
|
26 | 26 | vs. the original code.) |
27 | 27 | """ |
28 | 28 | import types, weakref |
29 | | from django.dispatch import saferef, robustapply, errors |
| 29 | from django.dispatch import saferef, robustapply, errors, signal |
30 | 30 | |
31 | 31 | __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" |
32 | 32 | __cvsid__ = "$Id: dispatcher.py,v 1.9 2005/09/17 04:55:57 mcfletch Exp $" |
33 | 33 | __version__ = "$Revision: 1.9 $"[11:-2] |
34 | 34 | |
35 | | |
36 | | class _Parameter: |
37 | | """Used to represent default parameter values.""" |
38 | | def __repr__(self): |
39 | | return self.__class__.__name__ |
40 | | |
41 | | class _Any(_Parameter): |
| 35 | Any = signal('Any', |
42 | 36 | """Singleton used to signal either "Any Sender" or "Any Signal" |
43 | 37 | |
44 | 38 | The Any object can be used with connect, disconnect, |
45 | 39 | send, or sendExact to signal that the parameter given |
46 | 40 | Any should react to all senders/signals, not just |
47 | 41 | a particular sender/signal. |
48 | | """ |
49 | | Any = _Any() |
| 42 | """) |
50 | 43 | |
51 | | class _Anonymous(_Parameter): |
| 44 | Anonymous = signal('Anonymous', |
52 | 45 | """Singleton used to signal "Anonymous Sender" |
53 | 46 | |
54 | 47 | The Anonymous object is used to signal that the sender |
… |
… |
|
65 | 58 | in either function then all messages are routed |
66 | 59 | as though there was a single sender (Anonymous) |
67 | 60 | being used everywhere. |
68 | | """ |
69 | | Anonymous = _Anonymous() |
| 61 | """) |
70 | 62 | |
71 | 63 | WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref) |
72 | 64 | |