Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: third_party/twisted_8_1/twisted/python/dispatch.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 import warnings
5 warnings.warn(
6 "Create your own event dispatching mechanism, "
7 "twisted.python.dispatch will soon be no more.",
8 DeprecationWarning, 2)
9
10
11 class EventDispatcher:
12 """
13 A global event dispatcher for events.
14 I'm used for any events that need to span disparate objects in the client.
15
16 I should only be used when one object needs to signal an object that it's
17 not got a direct reference to (unless you really want to pass it through
18 here, in which case I won't mind).
19
20 I'm mainly useful for complex GUIs.
21 """
22
23 def __init__(self, prefix="event_"):
24 self.prefix = prefix
25 self.callbacks = {}
26
27
28 def registerHandler(self, name, meth):
29 self.callbacks.setdefault(name, []).append(meth)
30
31
32 def autoRegister(self, obj):
33 from twisted.python import reflect
34 d = {}
35 reflect.accumulateMethods(obj, d, self.prefix)
36 for k,v in d.items():
37 self.registerHandler(k, v)
38
39
40 def publishEvent(self, name, *args, **kwargs):
41 for cb in self.callbacks[name]:
42 cb(*args, **kwargs)
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/python/deprecate.py ('k') | third_party/twisted_8_1/twisted/python/dist.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698