From eff3330e754cfbb496d6ba761d0a821375f575c8 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 12 Dec 2011 22:17:07 -0800 Subject: Add support for incoming/outgoing filters. A filter accepts and returns a stanza, but potentially modified. To prevent sending/receiving a stanza, a filter may return None. Incoming: self.add_filter('in', in_filter) Outgoing: self.add_filter('out', out_filter) Filters are applied in the order thay are added. However, you may add an order parameter, which is the place in the list to insert the filter: self.add_filter('in', in_filter, order=0) --- sleekxmpp/xmlstream/stanzabase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 389fe20c..2f864300 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -1251,7 +1251,7 @@ class StanzaBase(ElementBase): stanza sent immediately. Useful for stream initialization. Defaults to ``False``. """ - self.stream.send_raw(self.__str__(), now=now) + self.stream.send(self, now=now) def __copy__(self): """Return a copy of the stanza object that does not share the -- cgit v1.2.3 From 1a61bdb302e48d29888ab9b9cc23421bbb3fbead Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 28 Dec 2011 09:53:22 -0500 Subject: Ensure that stanza plugins work as expected if the XML is appended. --- sleekxmpp/xmlstream/stanzabase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 2f864300..8678ca14 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -345,7 +345,8 @@ class ElementBase(object): """ if attrib not in self.plugins: plugin_class = self.plugin_attrib_map[attrib] - plugin = plugin_class(parent=self) + existing_xml = self.xml.find(plugin_class.tag_name()) + plugin = plugin_class(parent=self, xml=existing_xml) self.plugins[attrib] = plugin if plugin_class in self.plugin_iterables: self.iterables.append(plugin) -- cgit v1.2.3