summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-02-14 01:24:09 -0800
committerLance Stout <lancestout@gmail.com>2013-02-14 01:24:09 -0800
commitd8c96623022835dece47e499245369aa68927300 (patch)
treefe1f2604f5b90e345a74144e3fc63f782dd728e3 /sleekxmpp/plugins
parentec5e819b16e5326638551b80464c0c3714b3dc3c (diff)
downloadslixmpp-d8c96623022835dece47e499245369aa68927300.tar.gz
slixmpp-d8c96623022835dece47e499245369aa68927300.tar.bz2
slixmpp-d8c96623022835dece47e499245369aa68927300.tar.xz
slixmpp-d8c96623022835dece47e499245369aa68927300.zip
Resolve most Python3.3 related issues.
Tests now run successfully. Occasionally get single error related to duplicated payload data in pubsub items when copying stanza values.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/xep_0004/stanza/field.py5
-rw-r--r--sleekxmpp/plugins/xep_0004/stanza/form.py12
-rw-r--r--sleekxmpp/plugins/xep_0060/pubsub.py2
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/pubsub.py40
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py3
5 files changed, 19 insertions, 43 deletions
diff --git a/sleekxmpp/plugins/xep_0004/stanza/field.py b/sleekxmpp/plugins/xep_0004/stanza/field.py
index 1e175966..51f85995 100644
--- a/sleekxmpp/plugins/xep_0004/stanza/field.py
+++ b/sleekxmpp/plugins/xep_0004/stanza/field.py
@@ -41,10 +41,11 @@ class FormField(ElementBase):
self._type = value
def add_option(self, label='', value=''):
- if self._type in self.option_types:
- opt = FieldOption(parent=self)
+ if self._type is None or self._type in self.option_types:
+ opt = FieldOption()
opt['label'] = label
opt['value'] = value
+ self.append(opt)
else:
raise ValueError("Cannot add options to " + \
"a %s field." % self['type'])
diff --git a/sleekxmpp/plugins/xep_0004/stanza/form.py b/sleekxmpp/plugins/xep_0004/stanza/form.py
index 721ecc35..bbd8540f 100644
--- a/sleekxmpp/plugins/xep_0004/stanza/form.py
+++ b/sleekxmpp/plugins/xep_0004/stanza/form.py
@@ -65,7 +65,7 @@ class Form(ElementBase):
if kwtype is None:
kwtype = ftype
- field = FormField(parent=self)
+ field = FormField()
field['var'] = var
field['type'] = kwtype
field['value'] = value
@@ -77,6 +77,7 @@ class Form(ElementBase):
field['options'] = options
else:
del field['type']
+ self.append(field)
return field
def getXML(self, type='submit'):
@@ -144,10 +145,9 @@ class Form(ElementBase):
def get_fields(self, use_dict=False):
fields = OrderedDict()
- fieldsXML = self.xml.findall('{%s}field' % FormField.namespace)
- for fieldXML in fieldsXML:
- field = FormField(xml=fieldXML)
- fields[field['var']] = field
+ for stanza in self['substanzas']:
+ if isinstance(stanza, FormField):
+ fields[stanza['var']] = stanza
return fields
def get_instructions(self):
@@ -221,6 +221,8 @@ class Form(ElementBase):
def set_values(self, values):
fields = self['fields']
for field in values:
+ if field not in fields:
+ fields[field] = self.add_field(var=field)
fields[field]['value'] = values[field]
def merge(self, other):
diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py
index 952cad85..bec5f565 100644
--- a/sleekxmpp/plugins/xep_0060/pubsub.py
+++ b/sleekxmpp/plugins/xep_0060/pubsub.py
@@ -423,7 +423,7 @@ class XEP_0060(BasePlugin):
callback=None, timeout=None):
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
iq['pubsub_owner']['configure']['node'] = node
- iq['pubsub_owner']['configure']['form'].values = config.values
+ iq['pubsub_owner']['configure'].append(config)
return iq.send(block=block, callback=callback, timeout=timeout)
def publish(self, jid, node, id=None, payload=None, options=None,
diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py
index b2fe3010..c1907a13 100644
--- a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py
+++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py
@@ -74,7 +74,12 @@ class Item(ElementBase):
def set_payload(self, value):
del self['payload']
- self.append(value)
+ if isinstance(value, ElementBase):
+ if value.tag_name() in self.plugin_tag_map:
+ self.init_plugin(value.plugin_attrib, existing_xml=value.xml)
+ self.xml.append(value.xml)
+ else:
+ self.xml.append(value)
def get_payload(self):
childs = list(self.xml)
@@ -243,39 +248,6 @@ class PublishOptions(ElementBase):
self.parent().xml.remove(self.xml)
-class PubsubState(ElementBase):
- """This is an experimental pubsub extension."""
- namespace = 'http://jabber.org/protocol/psstate'
- name = 'state'
- plugin_attrib = 'psstate'
- interfaces = set(('node', 'item', 'payload'))
-
- def set_payload(self, value):
- self.xml.append(value)
-
- def get_payload(self):
- childs = list(self.xml)
- if len(childs) > 0:
- return childs[0]
-
- def del_payload(self):
- for child in self.xml:
- self.xml.remove(child)
-
-
-class PubsubStateEvent(ElementBase):
- """This is an experimental pubsub extension."""
- namespace = 'http://jabber.org/protocol/psstate#event'
- name = 'event'
- plugin_attrib = 'psstate_event'
- intefaces = set(tuple())
-
-
-register_stanza_plugin(Iq, PubsubState)
-register_stanza_plugin(Message, PubsubStateEvent)
-register_stanza_plugin(PubsubStateEvent, PubsubState)
-
-
register_stanza_plugin(Iq, Pubsub)
register_stanza_plugin(Pubsub, Affiliations)
register_stanza_plugin(Pubsub, Configure)
diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py
index 4a35db9d..c10ac762 100644
--- a/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py
+++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py
@@ -34,7 +34,8 @@ class DefaultConfig(ElementBase):
return self['form']
def set_config(self, value):
- self['form'].values = value.values
+ del self['from']
+ self.append(value)
return self