From 35f33f1614de11409d4b452ad1e5a11e133e06c8 Mon Sep 17 00:00:00 2001 From: Matthieu Rakotojaona Date: Sat, 30 Aug 2014 17:23:27 +0200 Subject: Extend AtomEntry capabilities --- sleekxmpp/stanza/atom.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'sleekxmpp/stanza') diff --git a/sleekxmpp/stanza/atom.py b/sleekxmpp/stanza/atom.py index 244ef315..4e9591a5 100644 --- a/sleekxmpp/stanza/atom.py +++ b/sleekxmpp/stanza/atom.py @@ -6,8 +6,7 @@ See the file LICENSE for copying permission. """ -from sleekxmpp.xmlstream import ElementBase - +from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase class AtomEntry(ElementBase): @@ -22,5 +21,23 @@ class AtomEntry(ElementBase): namespace = 'http://www.w3.org/2005/Atom' name = 'entry' plugin_attrib = 'entry' - interfaces = set(('title', 'summary')) - sub_interfaces = set(('title', 'summary')) + interfaces = set(('title', 'summary', 'id', 'published', 'updated')) + sub_interfaces = set(('title', 'summary', 'id', 'published', + 'updated')) + +class AtomAuthor(ElementBase): + + """ + An Atom author. + + Stanza Interface: + name -- The printable author name + uri -- The bare jid of the author + """ + + name = 'author' + plugin_attrib = 'author' + interfaces = set(('name', 'uri')) + sub_interfaces = set(('name', 'uri')) + +register_stanza_plugin(AtomEntry, AtomAuthor) -- cgit v1.2.3 From f22d8e67b402f4756a497d8797e1526c2b7682a1 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 9 Sep 2014 08:49:37 -0700 Subject: Preserve ID for error responses Fixes #319 --- sleekxmpp/stanza/rootstanza.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sleekxmpp/stanza') diff --git a/sleekxmpp/stanza/rootstanza.py b/sleekxmpp/stanza/rootstanza.py index a7c2b218..52b807e5 100644 --- a/sleekxmpp/stanza/rootstanza.py +++ b/sleekxmpp/stanza/rootstanza.py @@ -60,7 +60,9 @@ class RootStanza(StanzaBase): self.send() elif isinstance(e, XMPPError): # We raised this deliberately + keep_id = self['id'] self.reply(clear=e.clear) + self['id'] = keep_id self['error']['condition'] = e.condition self['error']['text'] = e.text self['error']['type'] = e.etype @@ -72,7 +74,9 @@ class RootStanza(StanzaBase): self.send() else: # We probably didn't raise this on purpose, so send an error stanza + keep_id = self['id'] self.reply() + self['id'] = keep_id self['error']['condition'] = 'undefined-condition' self['error']['text'] = "SleekXMPP got into trouble." self['error']['type'] = 'cancel' -- cgit v1.2.3