summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-04-22 21:24:28 -0700
committerNathan Fritz <nathan@andyet.net>2010-04-22 21:24:28 -0700
commit602a6d8491171de5cccb332684813e71f5d33c43 (patch)
treedfdc53119b3c28ec0d5ec61eb47ebf515d6fcd77 /sleekxmpp
parent37b571c55ab00b3107a480027f0ba212831bf7ed (diff)
downloadslixmpp-602a6d8491171de5cccb332684813e71f5d33c43.tar.gz
slixmpp-602a6d8491171de5cccb332684813e71f5d33c43.tar.bz2
slixmpp-602a6d8491171de5cccb332684813e71f5d33c43.tar.xz
slixmpp-602a6d8491171de5cccb332684813e71f5d33c43.zip
bugfixes and continuing to work on pubsub tests
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/stanza_pubsub.py33
-rw-r--r--sleekxmpp/stanza/rootstanza.py6
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py10
3 files changed, 13 insertions, 36 deletions
diff --git a/sleekxmpp/plugins/stanza_pubsub.py b/sleekxmpp/plugins/stanza_pubsub.py
index 6ed84f1e..4187d49c 100644
--- a/sleekxmpp/plugins/stanza_pubsub.py
+++ b/sleekxmpp/plugins/stanza_pubsub.py
@@ -81,39 +81,6 @@ class Subscriptions(ElementBase):
plugin_tag_map = {}
subitem = (Subscription,)
- def __init__(self, *args, **kwargs):
- ElementBase.__init__(self, *args, **kwargs)
- self.subscriptions = []
- self.idx = 0
-
- def __iter__(self):
- self.idx = 0
- return self
-
- def __next__(self):
- self.idx += 1
- if self.idx + 1 > len(self.subscriptions):
- self.idx = 0
- raise StopIteration
- return self.subscriptions[self.idx]
-
- def __len__(self):
- return len(self.subscriptions)
-
- def append(self, subscription):
- if not isinstance(subscription, Subscription):
- raise TypeError
- self.xml.append(subscription.xml)
- return self.subscriptions.append(subscription)
-
- def pop(self, idx=0):
- aff = self.subscriptions.pop(idx)
- self.xml.remove(aff.xml)
- return aff
-
- def find(self, subscription):
- return self.subscriptions.find(subscription)
-
stanzaPlugin(Pubsub, Subscriptions)
class OptionalSetting(object):
diff --git a/sleekxmpp/stanza/rootstanza.py b/sleekxmpp/stanza/rootstanza.py
index 9c147e40..3b4822d8 100644
--- a/sleekxmpp/stanza/rootstanza.py
+++ b/sleekxmpp/stanza/rootstanza.py
@@ -10,6 +10,7 @@ from xml.etree import cElementTree as ET
from . error import Error
from .. exceptions import XMPPError
import traceback
+import sys
class RootStanza(StanzaBase):
@@ -24,7 +25,10 @@ class RootStanza(StanzaBase):
self['error']['type'] = e.etype
else: # we probably didn't raise this on purpose, so send back a traceback
self['error']['condition'] = 'undefined-condition'
- self['error']['text'] = traceback.format_tb(e.__traceback__)
+ if sys.version_info < (3,0):
+ self['error']['text'] = "SleekXMPP got into trouble."
+ else:
+ self['error']['text'] = traceback.format_tb(e.__traceback__)
self.send()
# all jabber:client root stanzas should have the error plugin
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index ae9e9df7..57c727a3 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -77,11 +77,14 @@ class ElementBase(tostring.ToString):
def __next__(self):
self.idx += 1
- if self.idx + 1 > len(self.iterables):
+ if self.idx > len(self.iterables):
self.idx = 0
raise StopIteration
- return self.affiliations[self.idx]
+ return self.iterables[self.idx - 1]
+ def next(self):
+ return self.__next__()
+
def __len__(self):
return len(self.iterables)
@@ -140,6 +143,9 @@ class ElementBase(tostring.ToString):
def find(self, xpath): # for backwards compatiblity, expose elementtree interface
return self.xml.find(xpath)
+
+ def findall(self, xpath):
+ return self.xml.findall(xpath)
def setup(self, xml=None):
if self.xml is None: