Initialize message handlers list in JCLComponent constructor

darcs-hash:20071204071304-86b55-6cf8201c40a62c4f36df187157aaa42e6acfdb77.gz
This commit is contained in:
David Rousselie
2007-12-04 08:13:04 +01:00
parent 36c21002b4
commit edc152010e
2 changed files with 10 additions and 5 deletions

View File

@@ -628,7 +628,8 @@ class JCLComponent(Component, object):
self.time_unit = 60
self.queue = Queue(100)
self.account_manager = account_manager_class(self)
self.msg_handlers = []
self.msg_handlers = [[PasswordMessageHandler(self),
HelpMessageHandler(self)]]
self.presence_subscribe_handlers = [[AccountPresenceSubscribeHandler(self),
RootPresenceSubscribeHandler(self)]]
self.presence_unsubscribe_handlers = [[AccountPresenceUnsubscribeHandler(self),
@@ -769,9 +770,6 @@ class JCLComponent(Component, object):
self.handle_message)
self.send_stanzas(self.account_manager.probe_all_accounts_presence())
self.msg_handlers += [[PasswordMessageHandler(self),
HelpMessageHandler(self)]]
def signal_handler(self, signum, frame):
"""Stop method handler
"""
@@ -824,7 +822,13 @@ class JCLComponent(Component, object):
apply_filter_func=None,
apply_handle_func=None,
send_result=True):
"""Execute handler if their filter method does not return None"""
"""
Execute handler if their filter method does not return None
`handlers` is a list of handler groups which is a list of groups.
Only one successfull handler (its filter and its handler methods
does not return None) per group is executed. When a handler is
executed successfully the next group is processed.
"""
result = []
lang_class = self.lang.get_lang_class_from_node(stanza.get_node())
for handler_group in handlers:

View File

@@ -81,5 +81,6 @@ class HelpMessageHandler(Handler):
"""
return [Message(to_jid=stanza.get_from(),
from_jid=stanza.get_to(),
stanza_type=stanza.get_type(),
subject=lang_class.help_message_subject,
body=lang_class.help_message_body)]