changeset 1432:60c41422ee48

tmp (rsm): better use of domish.Element.elements() + minor fixes
author Goffi <goffi@goffi.org>
date Wed, 27 May 2015 19:12:38 +0200
parents 70abe871eac3
children 5d42e2219d7c
files src/tmp/wokkel/rsm.py
diffstat 1 files changed, 11 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/tmp/wokkel/rsm.py	Wed May 27 19:12:38 2015 +0200
+++ b/src/tmp/wokkel/rsm.py	Wed May 27 19:12:38 2015 +0200
@@ -94,9 +94,7 @@
         @rtype: L{RSMRequest}
         """
         try:
-            set_elt = domish.generateElementsQNamed(element.elements(),
-                                                    name="set",
-                                                    uri=NS_RSM).next()
+            set_elt = element.elements(NS_RSM, 'set').next()
         except StopIteration:
             raise RSMNotFoundError()
 
@@ -194,9 +192,7 @@
         @rtype: L{RSMResponse}
         """
         try:
-            set_elt = domish.generateElementsQNamed(element.elements(),
-                                                    name="set",
-                                                    uri=NS_RSM).next()
+            set_elt = element.elements(NS_RSM, 'set').next()
         except StopIteration:
             return RSMNotFoundError()
 
@@ -331,9 +327,8 @@
         def cb(iq):
             items = []
             if iq.pubsub.items:
-                for element in iq.pubsub.items.elements():
-                    if element.uri == pubsub.NS_PUBSUB and element.name == 'item':
-                        items.append(element)
+                for element in iq.pubsub.items.elements(pubsub.NS_PUBSUB, 'item'):
+                    items.append(element)
 
             if request.rsm:
                 response = RSMResponse.parse(iq.pubsub)
@@ -345,21 +340,20 @@
         d.addCallback(cb)
         return d
 
-    def getRSMResponse(self, id):
-        """
-        Post-retrieve the RSM response data after items retrieval is done.
+    def getRSMResponse(self, id_):
+        """Post-retrieve the RSM response data after items retrieval is done.
 
-        @param id: extension data ID
-        @type id: C{unicode}
+        @param id_: extension data ID
+        @type id_: C{unicode}
 
         @return: dict representation of the RSM response.
         @rtype: C{dict} of C{unicode}
         """
         # This method exists to not modify the return value of self.items.
-        if id not in self._rsm_responses:
+        if id_ not in self._rsm_responses:
             return {}
-        result = self._rsm_responses[id].toDict()
-        del self._rsm_responses[id]
+        result = self._rsm_responses[id_].toDict()
+        del self._rsm_responses[id_]
         return result