From 520bf72e1113f3621658c7090a676e7d4fa63013 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 22 May 2010 22:40:30 +0800 Subject: Modified the return values for several methods so that they can be chained. For example: iq.reply().error().setPayload(something.xml).send() --- sleekxmpp/xmlstream/stanzabase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 018e81c3..3f3f5e08 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -332,7 +332,7 @@ class StanzaBase(ElementBase): def setType(self, value): if value in self.types: - self.xml.attrib['type'] = value + self.xml.attrib['type'] = value return self def getPayload(self): @@ -340,15 +340,18 @@ class StanzaBase(ElementBase): def setPayload(self, value): self.xml.append(value) + return self def delPayload(self): self.clear() + return self def clear(self): for child in self.xml.getchildren(): self.xml.remove(child) for plugin in list(self.plugins.keys()): del self.plugins[plugin] + return self def reply(self): self['from'], self['to'] = self['to'], self['from'] @@ -357,6 +360,7 @@ class StanzaBase(ElementBase): def error(self): self['type'] = 'error' + return self def getTo(self): return JID(self._getAttr('to')) -- cgit v1.2.3 From 194e6bcb5149f145c389fa8837dbe902557d9215 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Thu, 27 May 2010 19:58:57 +0800 Subject: added pubsub state stanzas and scheduled events --- sleekxmpp/xmlstream/stanzabase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 3f3f5e08..c40922be 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -319,6 +319,8 @@ class StanzaBase(ElementBase): def __init__(self, stream=None, xml=None, stype=None, sto=None, sfrom=None, sid=None): self.stream = stream + if stream is not None: + self.namespace = stream.default_ns ElementBase.__init__(self, xml) if stype is not None: self['type'] = stype @@ -326,8 +328,6 @@ class StanzaBase(ElementBase): self['to'] = sto if sfrom is not None: self['from'] = sfrom - if stream is not None: - self.namespace = stream.default_ns self.tag = "{%s}%s" % (self.namespace, self.name) def setType(self, value): -- cgit v1.2.3 From ecf902bf16abbcfab0243d4ecd6e7d41967b121a Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Mon, 31 May 2010 18:36:25 +0800 Subject: Scheduler waits too longer, and pubsubstate registration was backwards --- sleekxmpp/xmlstream/stanzabase.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index c40922be..64020c8f 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -78,6 +78,9 @@ class ElementBase(tostring.ToString): def __iter__(self): self.idx = 0 return self + + def __bool__(self): + return True def __next__(self): self.idx += 1 -- cgit v1.2.3