diff engine/extensions/pychan/events.py @ 166:81a222e7bd25

Fixes for event handling.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 18 Oct 2008 06:46:21 +0000
parents 5b04a7d3ded6
children 06dddc96ce54
line wrap: on
line diff
--- a/engine/extensions/pychan/events.py	Wed Oct 15 18:04:52 2008 +0000
+++ b/engine/extensions/pychan/events.py	Sat Oct 18 06:46:21 2008 +0000
@@ -168,8 +168,10 @@
 			raise exceptions.RuntimeError("Unknown eventname: " + event_name)
 
 		if callback is None:
-			if self.isCaptured(event_name):
+			if self.isCaptured(event_name,group_name):
 				del self.listener.events[event_name][group_name]
+				if not self.listener.events[event_name]:
+					del self.listener.events[event_name]
 				if not self.listener.events:
 					self.detach()
 			elif self.debug:
@@ -188,7 +190,7 @@
 			self.listener.events[event_name][group_name] = captured_f
 		self.attach()
 
-	def isCaptured(self,event_name,group_name):
+	def isCaptured(self,event_name,group_name="default"):
 		return event_name in self.listener.events and group_name in self.listener.events[event_name]
 
 	def getCapturedEvents(self):