##// END OF EJS Templates
changed notification.py instance variables to underscore_case
Barry Wark -
Show More
@@ -2,7 +2,7 b''
2
2
3 """The IPython Core Notification Center.
3 """The IPython Core Notification Center.
4
4
5 See docs/blueprints/notification_blueprint.txt for an overview of the
5 See docs/source/development/notification_blueprint.txt for an overview of the
6 notification module.
6 notification module.
7 """
7 """
8
8
@@ -27,7 +27,7 b' class NotificationCenter(object):'
27 ...
27 ...
28 >>> notification.sharedCenter.add_observer(callback, 'NOTIFICATION_TYPE', None)
28 >>> notification.sharedCenter.add_observer(callback, 'NOTIFICATION_TYPE', None)
29 >>> notification.sharedCenter.post_notification('NOTIFICATION_TYPE', object())
29 >>> notification.sharedCenter.post_notification('NOTIFICATION_TYPE', object())
30 NOTIFICATION_TYPE <object object at 0x284b0> {}
30 NOTIFICATION_TYPE ...
31
31
32 """
32 """
33 def __init__(self):
33 def __init__(self):
@@ -38,8 +38,8 b' class NotificationCenter(object):'
38 def _init_observers(self):
38 def _init_observers(self):
39 """Initialize observer storage"""
39 """Initialize observer storage"""
40
40
41 self.registeredTypes = set() #set of types that are observed
41 self.registered_types = set() #set of types that are observed
42 self.registeredSenders = set() #set of senders that are observed
42 self.registered_senders = set() #set of senders that are observed
43 self.observers = {} #map (type,sender) => callback (callable)
43 self.observers = {} #map (type,sender) => callback (callable)
44
44
45
45
@@ -59,9 +59,10 b' class NotificationCenter(object):'
59 type and sender.")
59 type and sender.")
60
60
61 # If there are no registered observers for the type/sender pair
61 # If there are no registered observers for the type/sender pair
62 if((theType not in self.registeredTypes and None not in self.registeredTypes) or
62 if((theType not in self.registered_types and
63 (sender not in self.registeredSenders and None not in self.registeredSenders)):
63 None not in self.registered_types) or
64 print theType,sender,self.registeredTypes,self.registeredSenders
64 (sender not in self.registered_senders and
65 None not in self.registered_senders)):
65 return
66 return
66
67
67 for o in self._observers_for_notification(theType, sender):
68 for o in self._observers_for_notification(theType, sender):
@@ -108,8 +109,8 b' class NotificationCenter(object):'
108 will be posted.
109 will be posted.
109 """
110 """
110 assert(callback != None)
111 assert(callback != None)
111 self.registeredTypes.add(theType)
112 self.registered_types.add(theType)
112 self.registeredSenders.add(sender)
113 self.registered_senders.add(sender)
113 self.observers.setdefault((theType,sender), set()).add(callback)
114 self.observers.setdefault((theType,sender), set()).add(callback)
114
115
115 def remove_all_observers(self):
116 def remove_all_observers(self):
General Comments 0
You need to be logged in to leave comments. Login now