From 7ac75de19df11ab992bd3d1a60b0154101dce655 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 1 Apr 2013 20:57:16 -0700 Subject: Make XMLMasks match properly for components. --- sleekxmpp/xmlstream/matcher/xmlmask.py | 4 ++-- sleekxmpp/xmlstream/xmlstream.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'sleekxmpp') diff --git a/sleekxmpp/xmlstream/matcher/xmlmask.py b/sleekxmpp/xmlstream/matcher/xmlmask.py index cb202448..56f728e1 100644 --- a/sleekxmpp/xmlstream/matcher/xmlmask.py +++ b/sleekxmpp/xmlstream/matcher/xmlmask.py @@ -37,11 +37,11 @@ class MatchXMLMask(MatcherBase): object or XML string to use as a mask. """ - def __init__(self, criteria): + def __init__(self, criteria, default_ns='jabber:client'): MatcherBase.__init__(self, criteria) if isinstance(criteria, str): self._criteria = ET.fromstring(self._criteria) - self.default_ns = 'jabber:client' + self.default_ns = default_ns def setDefaultNS(self, ns): """Set the default namespace to use during comparisons. diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 1c0b84b9..55074932 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -1017,8 +1017,12 @@ class XMLStream(object): if name is None: name = 'add_handler_%s' % self.new_id() - self.register_handler(XMLCallback(name, MatchXMLMask(mask), pointer, - once=disposable, instream=instream)) + self.register_handler( + XMLCallback(name, + MatchXMLMask(mask, self.default_ns), + pointer, + once=disposable, + instream=instream)) def register_handler(self, handler, before=None, after=None): """Add a stream event handler that will be executed when a matching -- cgit v1.2.3