[Commits] (pavlov) making it possible to send a notification to a certain thread

commits at osafoundation.org commits at osafoundation.org
Tue Jan 27 12:54:01 PST 2004


Commit by: pavlov
Modified files:
osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py 1.4 1.5
osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py 1.9 1.10

Log message:
making it possible to send a notification to a certain thread


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py.diff?r1=text&tr1=1.9&r2=text&tr2=1.10

Index: osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py:1.4 osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py:1.5
--- osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py:1.4	Tue Jan 20 15:39:21 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/notifications/Notification.py	Tue Jan 27 12:53:31 2004
@@ -1,16 +1,17 @@
-__version__ = "$Revision: 1.4 $"
-__date__ = "$Date: 2004/01/20 23:39:21 $"
+__version__ = "$Revision: 1.5 $"
+__date__ = "$Date: 2004/01/27 20:53:31 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 import application.Globals as Globals
 
 class Notification(object):
-    __slots__ = [ 'data', '__eventUUID' ]
+    __slots__ = [ 'data', '__eventUUID', 'threadid' ]
     def __init__(self, event, *args):
         super(Notification, self).__init__()
         self.__eventUUID = event.getUUID()
         self.data = None
+        self.threadid = None
 
     def __getEvent(self):
         return Globals.repository[self.__eventUUID]

Index: osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py:1.9 osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py:1.10
--- osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py:1.9	Tue Jan 20 15:39:21 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/notifications/NotificationManager.py	Tue Jan 27 12:53:31 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.9 $"
-__date__ = "$Date: 2004/01/20 23:39:21 $"
+__version__ = "$Revision: 1.10 $"
+__date__ = "$Date: 2004/01/27 20:53:31 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -92,7 +92,7 @@
         finally:
             self.declarations.release()
 
-    def PostNotification(self, notification):
+    def PostNotification(self, notification, sender = None):
         # for now we don't care who posts......
         # future version should check notification for validity
         self.declarations.acquire()
@@ -155,17 +155,22 @@
     event = property(__getEvent)
 
 class Subscription(object):
-    __slots__ = [ 'declarations', 'queue', 'callback', 'args' ]
+    __slots__ = [ 'declarations', 'queue', 'callback', 'args', 'threadid' ]
     def __init__(self, declarations, callback, *args):
         super(Subscription, self).__init__()
         self.declarations = declarations
         self.callback = callback
         self.args = args
+        self.threadid = id(threading.currentThread())
         if not callable(callback):
             self.queue = Queue.Queue()
 
     def post(self, notification):
         if callable(self.callback):
+            if notification.threadid != None:
+                if notification.threadid != id(threading.currentThread()):
+                    print 'ignoring notification from', notification.threadid
+                    return
             self.callback(notification, *self.args)
         else:
             self.queue.put(notification)



More information about the Commits mailing list