summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0004.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-11-17 02:00:20 -0500
committerLance Stout <lancestout@gmail.com>2010-11-17 02:01:12 -0500
commit26aca2b789f62123819041229ba40ab10268f49e (patch)
tree20388fb0559ed85f7143eb3b8a669142cdc43f6b /sleekxmpp/plugins/xep_0004.py
parent4f69a03bb1a8caab7899bd04f97b7975a78f2f34 (diff)
parent5424ede413393db5b835686e8544a9b703fb113b (diff)
downloadslixmpp-26aca2b789f62123819041229ba40ab10268f49e.tar.gz
slixmpp-26aca2b789f62123819041229ba40ab10268f49e.tar.bz2
slixmpp-26aca2b789f62123819041229ba40ab10268f49e.tar.xz
slixmpp-26aca2b789f62123819041229ba40ab10268f49e.zip
Merge branch 'roster' of github.com:fritzy/SleekXMPP into roster
Conflicts: sleekxmpp/basexmpp.py sleekxmpp/roster.py sleekxmpp/test/sleektest.py tests/test_stream_presence.py tests/test_stream_roster.py
Diffstat (limited to 'sleekxmpp/plugins/xep_0004.py')
-rw-r--r--sleekxmpp/plugins/xep_0004.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/sleekxmpp/plugins/xep_0004.py b/sleekxmpp/plugins/xep_0004.py
index e8dba74c..b8b7ebfa 100644
--- a/sleekxmpp/plugins/xep_0004.py
+++ b/sleekxmpp/plugins/xep_0004.py
@@ -16,6 +16,9 @@ from .. stanza.message import Message
import types
+log = logging.getLogger(__name__)
+
+
class Form(ElementBase):
namespace = 'jabber:x:data'
name = 'x'
@@ -33,7 +36,7 @@ class Form(ElementBase):
if title is not None:
self['title'] = title
self.field = FieldAccessor(self)
-
+
def setup(self, xml=None):
if ElementBase.setup(self, xml): #if we had to generate xml
self['type'] = 'form'
@@ -55,11 +58,11 @@ class Form(ElementBase):
return field
def getXML(self, type='submit'):
- logging.warning("Form.getXML() is deprecated API compatibility with plugins/old_0004.py")
+ log.warning("Form.getXML() is deprecated API compatibility with plugins/old_0004.py")
return self.xml
-
+
def fromXML(self, xml):
- logging.warning("Form.fromXML() is deprecated API compatibility with plugins/old_0004.py")
+ log.warning("Form.fromXML() is deprecated API compatibility with plugins/old_0004.py")
n = Form(xml=xml)
return n
@@ -113,10 +116,10 @@ class Form(ElementBase):
reportedXML = self.xml.find('{%s}reported' % self.namespace)
if reportedXML is not None:
self.xml.remove(reportedXML)
-
+
def getFields(self, use_dict=False):
fields = {} if use_dict else []
- fieldsXML = self.xml.findall('{%s}field' % FormField.namespace)
+ fieldsXML = self.xml.findall('{%s}field' % FormField.namespace)
for fieldXML in fieldsXML:
field = FormField(xml=fieldXML)
if use_dict:
@@ -144,7 +147,7 @@ class Form(ElementBase):
def getReported(self):
fields = {}
- fieldsXML = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
+ fieldsXML = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
FormField.namespace))
for fieldXML in fieldsXML:
field = FormField(xml=fieldXML)
@@ -197,7 +200,7 @@ class Form(ElementBase):
fields = self.getFields(use_dict=True)
for field in values:
fields[field]['value'] = values[field]
-
+
def merge(self, other):
new = copy.copy(self)
if type(other) == types.DictType:
@@ -212,7 +215,7 @@ class Form(ElementBase):
class FieldAccessor(object):
def __init__(self, form):
self.form = form
-
+
def __getitem__(self, key):
return self.form.getFields(use_dict=True)[key]
@@ -366,21 +369,21 @@ class xep_0004(base.base_plugin):
self.xmpp.registerHandler(
Callback('Data Form',
- MatchXPath('{%s}message/{%s}x' % (self.xmpp.default_ns,
+ MatchXPath('{%s}message/{%s}x' % (self.xmpp.default_ns,
Form.namespace)),
self.handle_form))
registerStanzaPlugin(FormField, FieldOption)
registerStanzaPlugin(Form, FormField)
registerStanzaPlugin(Message, Form)
-
+
def makeForm(self, ftype='form', title='', instructions=''):
f = Form()
f['type'] = ftype
f['title'] = title
f['instructions'] = instructions
return f
-
+
def post_init(self):
base.base_plugin.post_init(self)
self.xmpp.plugin['xep_0030'].add_feature('jabber:x:data')