From 148b71e4d29fbf62bebd63cb269eddb7ed55ea14 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Tue, 30 Oct 2007 07:53:37 +0100 Subject: [PATCH] Make command_manager configurable in JCLComponent constructor darcs-hash:20071030065337-86b55-78f7398a8c3ac66d8483c824e681ace268e15db5.gz --- src/jcl/jabber/command.py | 2 +- src/jcl/jabber/component.py | 5 +++-- src/jcl/jabber/feeder.py | 7 +++++-- src/jcl/jabber/tests/command.py | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/jcl/jabber/command.py b/src/jcl/jabber/command.py index ce77bab..7655aef 100644 --- a/src/jcl/jabber/command.py +++ b/src/jcl/jabber/command.py @@ -50,7 +50,7 @@ STATUS_CANCELED = "canceled" root_node_re = re.compile("^[^@/]+$") account_type_node_re = re.compile("^[^@/]+/.*$") -account_node_re = re.compile("^[^@/]+@[^/]+/.*$") +account_node_re = re.compile("^[^@/]+@[^/]+/?.*$") class FieldNoType(Field): def complete_xml_element(self, xmlnode, doc): diff --git a/src/jcl/jabber/component.py b/src/jcl/jabber/component.py index 0c28c36..3cd40ad 100644 --- a/src/jcl/jabber/component.py +++ b/src/jcl/jabber/component.py @@ -594,7 +594,8 @@ class JCLComponent(Component, object): disco_category="headline", disco_type="x-unknown", lang=Lang(), - account_manager_class=AccountManager): + account_manager_class=AccountManager, + command_manager_class=JCLCommandManager): Component.__init__(self, JID(jid), secret, @@ -620,7 +621,7 @@ class JCLComponent(Component, object): RootPresenceAvailableHandler(self)]] self.presence_unavailable_handlers = [[AccountPresenceUnavailableHandler(self), RootPresenceUnavailableHandler(self)]] - command.command_manager = JCLCommandManager() + command.command_manager = command_manager_class() command.command_manager.component = self command.command_manager.account_manager = self.account_manager self.disco_get_items_handlers = [[RootDiscoGetItemsHandler(self), diff --git a/src/jcl/jabber/feeder.py b/src/jcl/jabber/feeder.py index 69c5f28..d5e8368 100644 --- a/src/jcl/jabber/feeder.py +++ b/src/jcl/jabber/feeder.py @@ -33,6 +33,7 @@ from jcl.jabber.component import JCLComponent, AccountManager from jcl.lang import Lang import jcl.model as model from jcl.model import account +from jcl.jabber.command import JCLCommandManager from pyxmpp.message import Message @@ -52,7 +53,8 @@ class FeederComponent(JCLComponent): config, config_file, lang=Lang(), - account_manager_class=AccountManager): + account_manager_class=AccountManager, + command_manager_class=JCLCommandManager): JCLComponent.__init__(self, jid, secret, @@ -61,7 +63,8 @@ class FeederComponent(JCLComponent): config, config_file, lang=lang, - account_manager_class=account_manager_class) + account_manager_class=account_manager_class, + command_manager_class=command_manager_class) # Define default feeder and sender, can be override self.handler = FeederHandler(Feeder(self), Sender(self)) self.check_interval = 1 diff --git a/src/jcl/jabber/tests/command.py b/src/jcl/jabber/tests/command.py index 568e998..b91de32 100644 --- a/src/jcl/jabber/tests/command.py +++ b/src/jcl/jabber/tests/command.py @@ -40,7 +40,7 @@ import jcl.jabber.command as command from jcl.jabber.command import FieldNoType, JCLCommandManager import jcl.model as model import jcl.model.account as account -from jcl.model.account import Account, LegacyJID, User +from jcl.model.account import Account, PresenceAccount, LegacyJID, User from jcl.model.tests.account import ExampleAccount, Example2Account from jcl.tests import JCLTestCase @@ -242,7 +242,7 @@ class CommandManager_TestCase(unittest.TestCase): class JCLCommandManager_TestCase(JCLTestCase): def setUp(self, tables=[]): - tables += [Account, ExampleAccount, + tables += [Account, PresenceAccount, ExampleAccount, Example2Account, LegacyJID, User] JCLTestCase.setUp(self, tables=tables)