annotate wokkel/rsm.py @ 6:dc3a3f454f39

tmp (wokkel): licenses fixes: the licenses headers were wrong, it was fixed: original work from Adrien Cossa is directly under AGPL v3 (with his agreement), work derivated from Wokkel is sublicensed to AGPL v3 as allowed by the original license, to stay consistent with the rest of the code base. Theses files (and only these ones) can be relicensed again to fill Wokkel license if Ralph plan to merge them upstream...
author Goffi <goffi@goffi.org>
date Thu, 23 Apr 2015 10:57:40 +0200
parents 4c3e159abf0b
children 1e21b4e94566
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1 # -*- test-case-name: wokkel.test.test_rsm -*-
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2 #
6
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
3 # SàT Wokkel extension for Result Set Management (XEP-0059)
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
4 # Copyright (C) 2015 Adien Cossa (souliane@mailoo.org)
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
5
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
6 # This program is free software: you can redistribute it and/or modify
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
9 # (at your option) any later version.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
10
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
11 # This program is distributed in the hope that it will be useful,
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
14 # GNU Affero General Public License for more details.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
15
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 5
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
18
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
19 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
20 XMPP Result Set Management protocol.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
21
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
22 This protocol is specified in
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
23 U{XEP-0059<http://xmpp.org/extensions/xep-0059.html>}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
24 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
25
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
26 from twisted.words.xish import domish
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
27
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
28 import pubsub
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
29 import copy
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
30
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
31
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
32 # RSM namespace
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
33 NS_RSM = 'http://jabber.org/protocol/rsm'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
34
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
35
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
36 class RSMError(Exception):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
37 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
38 RSM error.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
39 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
40
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
41
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
42 class RSMNotFoundError(Exception):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
43 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
44 An expected RSM element has not been found.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
45 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
46
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
47
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
48 class RSMRequest():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
49 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
50 A Result Set Management request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
51
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
52 @ivar max_: limit on the number of retrieved items.
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
53 @itype max_: C{int} or C{unicode}
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
54
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
55 @ivar index: starting index of the requested page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
56 @itype index: C{int} or C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
57
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
58 @ivar after: ID of the element immediately preceding the page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
59 @itype after: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
60
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
61 @ivar before: ID of the element immediately following the page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
62 @itype before: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
63 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
64
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
65 max_ = 10
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
66 index = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
67 after = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
68 before = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
69
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
70 def __init__(self, max_=None, index=None, after=None, before=None):
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
71 if max_ is not None:
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
72 max_ = int(max_)
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
73 assert max_ >= 0
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
74 self.max_ = max_
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
75
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
76 if index is not None:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
77 assert after is None and before is None
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
78 index = int(index)
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
79 assert index >= 0
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
80 self.index = index
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
81
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
82 if after is not None:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
83 assert before is None
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
84 assert isinstance(after, unicode)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
85 self.after = after
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
86
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
87 if before is not None:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
88 assert isinstance(before, unicode)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
89 self.before = before
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
90
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
91 @classmethod
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
92 def parse(cls, element):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
93 """Parse the given request element.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
94
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
95 @param element: request containing a set element.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
96 @type element: L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
97
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
98 @return: RSMRequest instance.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
99 @rtype: L{RSMRequest}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
100 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
101 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
102 set_elt = domish.generateElementsQNamed(element.elements(),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
103 name="set",
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
104 uri=NS_RSM).next()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
105 except StopIteration:
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
106 raise RSMNotFoundError()
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
107
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
108 request = RSMRequest()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
109 for elt in list(set_elt.elements()):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
110 if elt.name in ('before', 'after'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
111 setattr(request, elt.name, ''.join(elt.children))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
112 elif elt.name in ('max', 'index'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
113 setattr(request, elt.name, int(''.join(elt.children)))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
114
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
115 if request.max_ is None:
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
116 raise RSMError("RSM request is missing its 'max_' element")
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
117
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
118 return request
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
119
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
120 def toElement(self):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
121 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
122 Return the DOM representation of this RSM request.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
123
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
124 @rtype: L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
125 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
126 set_elt = domish.Element((NS_RSM, 'set'))
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
127 set_elt.addElement('max').addContent(unicode(self.max_))
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
128
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
129 if self.index is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
130 set_elt.addElement('index').addContent(unicode(self.index))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
131
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
132 if self.before is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
133 if self.before == '': # request the last page
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
134 set_elt.addElement('before')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
135 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
136 set_elt.addElement('before').addContent(self.before)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
137
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
138 if self.after is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
139 set_elt.addElement('after').addContent(self.after)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
140
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
141 return set_elt
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
142
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
143 def render(self, element):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
144 """Embed the DOM representation of this RSM request in the given element.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
145
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
146 @param element: Element to contain the RSM request.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
147 @type element: L{domish.Element}
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
148
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
149 @return: RSM request element.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
150 @rtype: L{domish.Element}
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
151 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
152 if element.name == 'pubsub' and hasattr(element, 'items'):
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
153 element.items.attributes['max_items'] = unicode(self.max_)
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
154
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
155 set_elt = self.toElement()
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
156 element.addChild(set_elt)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
157
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
158 return set_elt
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
159
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
160
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
161 class RSMResponse():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
162 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
163 A Result Set Management response.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
164
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
165 @ivar count: total number of items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
166 @itype count: C{int}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
167
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
168 @ivar index: starting index of the returned page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
169 @itype index: C{int}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
170
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
171 @ivar first: ID of the first element of the returned page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
172 @itype first: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
173
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
174 @ivar last: ID of the last element of the returned page.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
175 @itype last: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
176 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
177
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
178 count = 0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
179 index = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
180 first = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
181 last = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
182
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
183 def __init__(self, count=None, index=None, first=None, last=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
184 if count is not None:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
185 assert isinstance(count, int) and count >= 0
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
186 self.count = count
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
187
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
188 if index is not None:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
189 assert isinstance(index, int) and index >= 0
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
190 self.index = index
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
191 assert isinstance(first, unicode)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
192 self.first = first
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
193 assert isinstance(last, unicode)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
194 self.last = last
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
195 else:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
196 assert first is None and last is None
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
197
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
198 @classmethod
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
199 def parse(cls, element):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
200 """Parse the given response element.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
201
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
202 @param element: response element.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
203 @type element: L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
204
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
205 @return: RSMResponse instance.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
206 @rtype: L{RSMResponse}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
207 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
208 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
209 set_elt = domish.generateElementsQNamed(element.elements(),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
210 name="set",
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
211 uri=NS_RSM).next()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
212 except StopIteration:
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
213 return RSMNotFoundError()
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
214
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
215 response = RSMResponse()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
216 for elt in list(set_elt.elements()):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
217 if elt.name in ('first', 'last'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
218 setattr(response, elt.name, ''.join(elt.children))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
219 if elt.name == 'first':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
220 response.index = int(elt.getAttribute("index"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
221 elif elt.name == 'count':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
222 response.count = int(''.join(elt.children))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
223
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
224 if response.count is None:
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
225 raise RSMError("RSM response is missing its 'count' element")
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
226
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
227 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
228
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
229 def toElement(self):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
230 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
231 Return the DOM representation of this RSM request.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
232
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
233 @rtype: L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
234 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
235 set_elt = domish.Element((NS_RSM, 'set'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
236 set_elt.addElement('count').addContent(unicode(self.count))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
237
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
238 if self.index is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
239 first_elt = set_elt.addElement('first')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
240 first_elt.addContent(self.first)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
241 first_elt['index'] = unicode(self.index)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
242
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
243 set_elt.addElement('last').addContent(self.last)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
244
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
245 return set_elt
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
246
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
247 def render(self, element):
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
248 """Embed the DOM representation of this RSM response in the given element.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
249
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
250 @param element: Element to contain the RSM response.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
251 @type element: L{domish.Element}
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
252
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
253 @return: RSM request element.
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
254 @rtype: L{domish.Element}
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
255 """
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
256 set_elt = self.toElement()
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
257 element.addChild(set_elt)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
258 return set_elt
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
259
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
260 def toDict(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
261 """Return a dict representation of the object.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
262
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
263 @return: a dict of strings.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
264 @rtype: C{dict} binding C{unicode} to C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
265 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
266 result = {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
267 for attr in ('count', 'index', 'first', 'last'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
268 value = getattr(self, attr)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
269 if value is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
270 result[attr] = unicode(value)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
271 return result
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
272
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
273
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
274 class PubSubRequest(pubsub.PubSubRequest):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
275 """PubSubRequest extension to handle RSM.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
276
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
277 @ivar rsm: RSM request instance.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
278 @type rsm: L{RSMRequest}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
279 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
280
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
281 rsm = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
282
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
283 def __init__(self, verb=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
284 pubsub.PubSubRequest.__init__(self, verb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
285 self._parameters = copy.deepcopy(pubsub.PubSubRequest._parameters)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
286 self._parameters['items'].append('rsm')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
287
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
288 def _parse_rsm(self, verbElement):
1
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
289 try:
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
290 self.rsm = RSMRequest.parse(verbElement.parent)
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
291 except RSMNotFoundError:
9d35f88168a1 tmp: update tmp.wokkel.rsm, add tmp.wokkel.mam
souliane <souliane@mailoo.org>
parents: 0
diff changeset
292 self.rsm = None
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
293
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
294 def _render_rsm(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
295 if self.rsm:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
296 self.rsm.render(verbElement.parent)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
297
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
298
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
299 class PubSubClient(pubsub.PubSubClient):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
300 """PubSubClient extension to handle RSM."""
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
301
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
302 _rsm_responses = {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
303
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
304 def items(self, service, nodeIdentifier, maxItems=None, itemIdentifiers=None,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
305 subscriptionIdentifier=None, sender=None, ext_data=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
306 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
307 Retrieve previously published items from a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
308
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
309 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
310 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
311
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
312 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
313 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
314
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
315 @param maxItems: Optional limit on the number of retrieved items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
316 @type maxItems: C{int}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
317
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
318 @param itemIdentifiers: Identifiers of the items to be retrieved.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
319 @type itemIdentifiers: C{set}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
320
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
321 @param subscriptionIdentifier: Optional subscription identifier. In
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
322 case the node has been subscribed to multiple times, this narrows
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
323 the results to the specific subscription.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
324 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
325
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
326 @param ext_data: extension data.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
327 @type ext_data: L{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
328
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
329 @return: a Deferred that fires a C{list} of L{domish.Element}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
330 @rtype: L{defer.Deferred}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
331 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
332 request = PubSubRequest('items') # that's a rsm.PubSubRequest instance
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
333 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
334 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
335 if maxItems:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
336 request.maxItems = str(int(maxItems))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
337 request.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
338 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
339 request.itemIdentifiers = itemIdentifiers
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
340 if ext_data and 'rsm' in ext_data:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
341 request.rsm = ext_data['rsm']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
342
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
343 def cb(iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
344 items = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
345 if iq.pubsub.items:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
346 for element in iq.pubsub.items.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
347 if element.uri == pubsub.NS_PUBSUB and element.name == 'item':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
348 items.append(element)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
349
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
350 if request.rsm:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
351 response = RSMResponse.parse(iq.pubsub)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
352 if response is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
353 self._rsm_responses[ext_data['id']] = response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
354 return items
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
355
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
356 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
357 d.addCallback(cb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
358 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
359
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
360 def getRSMResponse(self, id):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
361 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
362 Post-retrieve the RSM response data after items retrieval is done.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
363
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
364 @param id: extension data ID
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
365 @type id: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
366
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
367 @return: dict representation of the RSM response.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
368 @rtype: C{dict} of C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
369 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
370 # This method exists to not modify the return value of self.items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
371 if id not in self._rsm_responses:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
372 return {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
373 result = self._rsm_responses[id].toDict()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
374 del self._rsm_responses[id]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
375 return result
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
376
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
377
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
378 class PubSubService(pubsub.PubSubService):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
379 """PubSubService extension to handle RSM."""
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
380
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
381 _request_class = PubSubRequest
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
382
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
383 def _toResponse_items(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
384 response = pubsub.PubSubService._toResponse_items(self, result,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
385 resource, request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
386 set_elts = [elt for elt in result if elt.name == 'set']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
387 if set_elts:
5
4c3e159abf0b plugins (groupblog, xep-0277) + tmp(rsm): improved style:
Goffi <goffi@goffi.org>
parents: 1
diff changeset
388 assert len(set_elts) == 1
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
389 response.addChild(set_elts[0])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
390
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
391 return response