Fix error in disco add_item.

None values were not being treated properly.
This commit is contained in:
Lance Stout 2011-01-19 12:08:28 -05:00
parent 2004ddd678
commit f1db2fc156
2 changed files with 8 additions and 4 deletions

View file

@ -345,7 +345,7 @@ class xep_0030(base_plugin):
""" """
self._run_node_handler('del_items', jid, node, kwargs) self._run_node_handler('del_items', jid, node, kwargs)
def add_item(self, jid=None, name='', node=None, subnode='', ijid=None): def add_item(self, jid='', name='', node=None, subnode='', ijid=None):
""" """
Add a new item element to the given JID/node combination. Add a new item element to the given JID/node combination.
@ -359,10 +359,12 @@ class xep_0030(base_plugin):
subnode -- Optional node for the item. subnode -- Optional node for the item.
ijid -- The JID to modify. ijid -- The JID to modify.
""" """
if jid is None:
jid = ''
kwargs = {'ijid': jid, kwargs = {'ijid': jid,
'name': name, 'name': name,
'inode': subnode} 'inode': subnode}
self._run_node_handler('add_item', jid, node, kwargs) self._run_node_handler('add_item', ijid, node, kwargs)
def del_item(self, jid=None, node=None, **kwargs): def del_item(self, jid=None, node=None, **kwargs):
""" """
@ -604,3 +606,4 @@ class xep_0030(base_plugin):
"Using default disco#info feature.") "Using default disco#info feature.")
info.add_feature(info.namespace) info.add_feature(info.namespace)
return info return info

View file

@ -247,8 +247,8 @@ class StaticDisco(object):
self.add_node(jid, node) self.add_node(jid, node)
self.nodes[(jid, node)]['items'].add_item( self.nodes[(jid, node)]['items'].add_item(
data.get('ijid', ''), data.get('ijid', ''),
node=data.get('inode', None), node=data.get('inode', ''),
name=data.get('name', None)) name=data.get('name', ''))
def del_item(self, jid, node, data): def del_item(self, jid, node, data):
""" """
@ -262,3 +262,4 @@ class StaticDisco(object):
self.nodes[(jid, node)]['items'].del_item( self.nodes[(jid, node)]['items'].del_item(
data.get('ijid', ''), data.get('ijid', ''),
node=data.get('inode', None)) node=data.get('inode', None))