annotate src/plugins/plugin_exp_pubsub_schema.py @ 2381:72c30e73a9a5

plugin schema: use new "prepend" argument to put "id" widget first.
author Goffi <goffi@goffi.org>
date Mon, 16 Oct 2017 07:36:41 +0200
parents 3704cb959ae8
children 2e05921df16a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for Pubsub Schemas
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2017 Jérôme Poisson (goffi@goffi.org)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from sat.core.i18n import _
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core import exceptions
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.constants import Const as C
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
23 from sat.tools import xml_tools
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.words.protocols.jabber import jid
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
26 from twisted.internet import defer
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from sat.core.log import getLogger
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 log = getLogger(__name__)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from wokkel import disco, iwokkel
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from wokkel import data_form
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from wokkel import generic
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from zope.interface import implements
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
33 from collections import Iterable
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35 NS_SCHEMA = 'https://salut-a-toi/protocol/schema:0'
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 NS_SCHEMA_FORM = 'https://salut-a-toi/protocol/schema#schema:0'
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 PLUGIN_INFO = {
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_NAME: "PubSub Schema",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_IMPORT_NAME: "PUBSUB_SCHEMA",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_TYPE: "EXP",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_PROTOCOLS: [],
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 C.PI_DEPENDENCIES: ["XEP-0060"],
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 C.PI_MAIN: "PubsubSchema",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 C.PI_HANDLER: "yes",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 C.PI_DESCRIPTION: _("""Handle Pubsub data schemas""")
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 }
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50 class PubsubSchema(object):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52 def __init__(self, host):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 log.info(_(u"PubSub Schema initialization"))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54 self.host = host
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
55 self._p = self.host.plugins["XEP-0060"]
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56 host.bridge.addMethod("psSchemaGet", ".plugin",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 in_sign='sss', out_sign='s',
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 method=self._getSchema,
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 async=True
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 )
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 host.bridge.addMethod("psSchemaSet", ".plugin",
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62 in_sign='ssss', out_sign='',
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 method=self._setSchema,
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 async=True
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 )
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
66 host.bridge.addMethod("psSchemaUIGet", ".plugin",
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
67 in_sign='sss', out_sign='s',
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
68 method=self._getUISchema,
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
69 async=True
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
70 )
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
71 host.bridge.addMethod("psItemsFormGet", ".plugin",
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
72 in_sign='ssssiassa{ss}s', out_sign='(asa{ss})',
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
73 method=self._getDataFormItems,
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
74 async=True)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
75 host.bridge.addMethod("psItemFormSend", ".plugin",
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
76 in_sign='ssa{sas}ssa{ss}s', out_sign='s',
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
77 method=self._sendDataFormItem,
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
78 async=True)
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80 def getHandler(self, client):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81 return SchemaHandler()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
82
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83 def _getSchemaBridgeCb(self, schema_elt):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84 if schema_elt is None:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
85 return u''
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
86 return schema_elt.toXml()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
87
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
88 def _getSchema(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
89 client = self.host.getClient(profile_key)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
90 service = None if not service else jid.JID(service)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
91 d = self.getSchema(client, service, nodeIdentifier)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
92 d.addCallback(self._getSchemaBridgeCb)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
93 return d
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
94
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 def _getSchemaCb(self, iq_elt):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
96 try:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
97 schema_elt = next(iq_elt.elements(NS_SCHEMA, 'schema'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
98 except StopIteration:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
99 raise exceptions.DataError('missing <schema> element')
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
100 schema_form = data_form.findForm(schema_elt, NS_SCHEMA_FORM)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
101 if schema_form is None:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
102 # there is not schema on this node
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103 return None
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104 # we get again the form because we need all elements/namespaces
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105 # while schema_form.toElement while only keep XEP-0004 elements
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 x_elt = next(schema_elt.elements(data_form.NS_X_DATA, 'x'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107 return x_elt
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
109 def getSchema(self, client, service, nodeIdentifier):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 """retrieve PubSub node schema
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
112 @param service(jid.JID, None): jid of PubSub service
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
113 None to use our PEP
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
114 @param nodeIdentifier(unicode): node to get schema from
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115 @return (domish.Element, None): schema (<x> element)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
116 None if not schema has been set on this node
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
117 """
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
118 iq_elt = client.IQ(u'get')
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
119 if service is not None:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120 iq_elt['to'] = service.full()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
121 pubsub_elt = iq_elt.addElement((NS_SCHEMA, 'pubsub'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
122 schema_elt = pubsub_elt.addElement((NS_SCHEMA, 'schema'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
123 schema_elt['node'] = nodeIdentifier
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
124 d = iq_elt.send()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
125 d.addCallback(self._getSchemaCb)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
126 return d
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
127
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
128 @defer.inlineCallbacks
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
129 def getSchemaForm(self, client, service, nodeIdentifier, schema=None, form_type='form'):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
130 """get data form from node's schema
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
131
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
132 @param service(None, jid.JID): PubSub service
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
133 @param nodeIdentifier(unicode): node
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
134 @param schema(domish.Element, data_form.Form, None): node schema
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
135 if domish.Element, will be converted to data form
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
136 if data_form.Form it will be returned without modification
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
137 if None, it will be retrieved from node (imply one additional XMPP request)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
138 @return(data_form.Form): data form
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
139 """
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
140 if schema is None:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
141 log.debug(_(u"unspecified schema, we need to request it"))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
142 schema = yield self.getSchema(client, service, nodeIdentifier)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
143 if schema is None:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
144 raise exceptions.DataError(_(u"no schema specified, and this node has no schema either, we can't construct the data form"))
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
145 elif isinstance(schema, data_form.Form):
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
146 defer.returnValue(schema)
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
147
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
148 try:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
149 form = data_form.Form.fromElement(schema)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
150 except data_form.Error as e:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
151 raise exceptions.DataError(_(u"Invalid Schema: {msg}").format(
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
152 msg = e))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
153 form.formType = form_type
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
154 defer.returnValue(form)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
155
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
156 def schema2XMLUI(self, schema_elt):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
157 form = data_form.Form.fromElement(schema_elt)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
158 xmlui = xml_tools.dataForm2XMLUI(form, '')
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
159 return xmlui
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
160
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
161 def _getUISchema(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
162 client = self.host.getClient(profile_key)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
163 service = None if not service else jid.JID(service)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
164 d = self.getUISchema(client, service, nodeIdentifier)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
165 d.addCallback(lambda xmlui: xmlui.toXml())
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
166 return d
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
167
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
168 def getUISchema(self, client, service, nodeIdentifier):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
169 d = self.getSchema(client, service, nodeIdentifier)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
170 d.addCallback(self.schema2XMLUI)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
171 return d
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
172
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
173 def _setSchema(self, service, nodeIdentifier, schema, profile_key=C.PROF_KEY_NONE):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
174 client = self.host.getClient(profile_key)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
175 service = None if not service else jid.JID(service)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
176 schema = generic.parseXml(schema.encode('utf-8'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
177 return self.setSchema(client, service, nodeIdentifier, schema)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
178
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def setSchema(self, client, service, nodeIdentifier, schema):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
180 """set or replace PubSub node schema
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
181
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
182 @param schema(domish.Element, None): schema to set
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
183 None if schema need to be removed
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
184 """
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
185 iq_elt = client.IQ()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
186 if service is not None:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
187 iq_elt['to'] = service.full()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
188 pubsub_elt = iq_elt.addElement((NS_SCHEMA, 'pubsub'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
189 schema_elt = pubsub_elt.addElement((NS_SCHEMA, 'schema'))
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
190 schema_elt['node'] = nodeIdentifier
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
191 if schema is not None:
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
192 schema_elt.addChild(schema)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
193 return iq_elt.send()
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
194
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
195 def _getDataFormItems(self, form_ns='', service='', node='', schema='', max_items=10, item_ids=None, sub_id=None, extra_dict=None, profile_key=C.PROF_KEY_NONE):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
196 client = self.host.getClient(profile_key)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
197 service = jid.JID(service) if service else None
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
198 if schema:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
199 schema = generic.parseXml(schema.encode('utf-8'))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
200 else:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
201 schema = None
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
202 max_items = None if max_items == C.NO_LIMIT else max_items
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
203 extra = self._p.parseExtra(extra_dict)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
204 d = self.getDataFormItems(client, form_ns or None, service, node or None, schema, max_items or None, item_ids, sub_id or None, extra.rsm_request, extra.extra)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
205 d.addCallback(self._p.serItemsData)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
206 return d
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
207
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
208 @defer.inlineCallbacks
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
209 def getDataFormItems(self, client, form_ns, service, nodeIdentifier, schema=None, max_items=None, item_ids=None, sub_id=None, rsm_request=None, extra=None):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
210 """Get items known as being data forms, and convert them to XMLUI
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
211
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
212 @param form_ns (unicode, None): namespace of the form
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
213 None to accept everything, even if form has no namespace
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
214 @param schema(domish.Element, data_form.Form, None): schema of the node if known
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
215 if None, it will be retrieved from node
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
216 other parameters as the same as for [getItems]
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
217 @return (list[unicode]): XMLUI of the forms
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
218 if an item is invalid (not corresponding to form_ns or not a data_form)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
219 it will be skipped
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
220 """
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
221 # we need the initial form to get options of fields when suitable
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
222 schema_form = yield self.getSchemaForm(client, service, nodeIdentifier, schema, form_type='result')
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
223 items_data = yield self._p.getItems(client, service, nodeIdentifier, max_items, item_ids, sub_id, rsm_request, extra)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
224 items, metadata = items_data
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
225 items_xmlui = []
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
226 for item_elt in items:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
227 for x_elt in item_elt.elements((data_form.NS_X_DATA, u'x')):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
228 form = data_form.Form.fromElement(x_elt)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
229 if form_ns and form.formNamespace != form_ns:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
230 continue
2381
72c30e73a9a5 plugin schema: use new "prepend" argument to put "id" widget first.
Goffi <goffi@goffi.org>
parents: 2378
diff changeset
231 xmlui = xml_tools.dataFormResult2XMLUI(
72c30e73a9a5 plugin schema: use new "prepend" argument to put "id" widget first.
Goffi <goffi@goffi.org>
parents: 2378
diff changeset
232 form,
72c30e73a9a5 plugin schema: use new "prepend" argument to put "id" widget first.
Goffi <goffi@goffi.org>
parents: 2378
diff changeset
233 schema_form,
72c30e73a9a5 plugin schema: use new "prepend" argument to put "id" widget first.
Goffi <goffi@goffi.org>
parents: 2378
diff changeset
234 prepend = (('label', 'id'),('text', item_elt['id'], u'id'))
72c30e73a9a5 plugin schema: use new "prepend" argument to put "id" widget first.
Goffi <goffi@goffi.org>
parents: 2378
diff changeset
235 )
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
236 items_xmlui.append(xmlui)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
237 break
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
238 defer.returnValue((items_xmlui, metadata))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
239
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
240
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
241 def _sendDataFormItem(self, service, nodeIdentifier, values, schema=None, item_id=None, extra=None, profile_key=C.PROF_KEY_NONE):
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
242 client = self.host.getClient(profile_key)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
243 service = None if not service else jid.JID(service)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
244 if schema:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
245 schema = generic.parseXml(schema.encode('utf-8'))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
246 else:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
247 schema = None
2378
3704cb959ae8 plugin schema: deserialise is now the last kw argument
Goffi <goffi@goffi.org>
parents: 2371
diff changeset
248 d = self.sendDataFormItem(client, service, nodeIdentifier, values, schema, item_id or None, extra, deserialise=True)
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
249 d.addCallback(lambda ret: ret or u'')
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
250 return d
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
251
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
252 @defer.inlineCallbacks
2378
3704cb959ae8 plugin schema: deserialise is now the last kw argument
Goffi <goffi@goffi.org>
parents: 2371
diff changeset
253 def sendDataFormItem(self, client, service, nodeIdentifier, values, schema=None, item_id=None, extra=None, deserialise=False):
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
254 """Publish an item as a dataform when we know that there is a schema
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
255
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
256 @param values(dict[[iterable[object], object]): values set for the form
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
257 if not iterable, will be put in a list
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
258 @param schema(domish.Element, data_form.Form, None): data schema
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
259 None to retrieve data schema from node (need to do a additional XMPP call)
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
260 Schema is needed to construct data form to publish
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
261 @param deserialise(bool): if True, data are list of unicode and must be deserialized according to expected type
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
262 This is done in this method and not directly in _sendDataFormItem because we need to know the data type
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
263 which is in the form, not availablable in _sendDataFormItem
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
264 other parameters as the same as for [self._p.sendItem]
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
265 """
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
266 form = yield self.getSchemaForm(client, service, nodeIdentifier, schema, form_type='submit')
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
267
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
268 for name, values_list in values.iteritems():
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
269 try:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
270 field = form.fields[name]
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
271 except KeyError:
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
272 log.warning(_(u"field {name} doesn't exist, ignoring it").format(name=name))
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
273 continue
2371
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
274 if isinstance(values_list, basestring) or not isinstance(values_list, Iterable):
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
275 values_list = [values_list]
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
276 if deserialise:
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
277 if field.fieldType == 'boolean':
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
278 values_list = [C.bool(v) for v in values_list]
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
279 elif 'jid' in field.fieldType:
2268df8c99bf plugin pubsub schema: values handling:
Goffi <goffi@goffi.org>
parents: 2363
diff changeset
280 values_list = [jid.JID(v) for v in values_list]
2363
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
281 field.values = values_list
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
282
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
283 yield self._p.sendItem(client, service, nodeIdentifier, form.toElement(), item_id, extra)
41c7717b52cd plugin PubSub Schema: schema helper methods:
Goffi <goffi@goffi.org>
parents: 2350
diff changeset
284
2350
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
285
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
286 class SchemaHandler(XMPPHandler):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
287 implements(iwokkel.IDisco)
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
288
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
289 def getDiscoInfo(self, requestor, service, nodeIdentifier=''):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
290 return [disco.DiscoFeature(NS_SCHEMA)]
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
291
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
292 def getDiscoItems(self, requestor, service, nodeIdentifier=''):
388226e9c3ff plugin schema: PubSub node schema, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
293 return []