changeset 1772:666ab06a9d81

tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
author Goffi <goffi@goffi.org>
date Tue, 05 Jan 2016 23:20:22 +0100
parents b77dc676a4df
children 6e867caf4621
files src/tmp/wokkel/pubsub.py
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/tmp/wokkel/pubsub.py	Tue Jan 05 23:20:20 2016 +0100
+++ b/src/tmp/wokkel/pubsub.py	Tue Jan 05 23:20:22 2016 +0100
@@ -759,8 +759,9 @@
     """
     Publish subscribe client protocol.
     """
+    implements(IPubSubClient)
 
-    implements(IPubSubClient)
+    _request_class = PubSubRequest
 
     def connectionInitialized(self):
         self.xmlstream.addObserver('/message/event[@xmlns="%s"]' %
@@ -841,7 +842,7 @@
         @param options: Optional node configuration options.
         @type options: C{dict}
         """
-        request = PubSubRequest('create')
+        request = self._request_class('create')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.sender = sender
@@ -874,7 +875,7 @@
         @param nodeIdentifier: The identifier of the node.
         @type nodeIdentifier: C{unicode}
         """
-        request = PubSubRequest('delete')
+        request = self._request_class('delete')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.sender = sender
@@ -903,7 +904,7 @@
             L{SubscriptionPending} or L{SubscriptionUnconfigured}.
         @rtype: L{defer.Deferred}
         """
-        request = PubSubRequest('subscribe')
+        request = self._request_class('subscribe')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.subscriber = subscriber
@@ -950,7 +951,7 @@
         @param subscriptionIdentifier: Optional subscription identifier.
         @type subscriptionIdentifier: C{unicode}
         """
-        request = PubSubRequest('unsubscribe')
+        request = self._request_class('unsubscribe')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.subscriber = subscriber
@@ -970,7 +971,7 @@
         @param items: Optional list of L{Item}s to publish.
         @type items: C{list}
         """
-        request = PubSubRequest('publish')
+        request = self._request_class('publish')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.items = items
@@ -1000,7 +1001,7 @@
             the results to the specific subscription.
         @type subscriptionIdentifier: C{unicode}
         """
-        request = PubSubRequest('items')
+        request = self._request_class('items')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         if maxItems:
@@ -1033,7 +1034,7 @@
         @param notify: True if notification is required
         @type notify: C{unicode}
         """
-        request = PubSubRequest('retract')
+        request = self._request_class('retract')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.itemIdentifiers = itemIdentifiers
@@ -1060,7 +1061,7 @@
 
         @rtype: L{data_form.Form}
         """
-        request = PubSubRequest('optionsGet')
+        request = self._request_class('optionsGet')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.subscriber = subscriber
@@ -1098,7 +1099,7 @@
         @param subscriptionIdentifier: Optional subscription identifier.
         @type subscriptionIdentifier: C{unicode}
         """
-        request = PubSubRequest('optionsSet')
+        request = self._request_class('optionsSet')
         request.recipient = service
         request.nodeIdentifier = nodeIdentifier
         request.subscriber = subscriber
@@ -1218,7 +1219,7 @@
 
         info = []
 
-        request = PubSubRequest('discoInfo')
+        request = self._request_class('discoInfo')
 
         if self.resource is not None:
             resource = self.resource.locateResource(request)
@@ -1250,7 +1251,7 @@
         if self.hideNodes:
             d = defer.succeed([])
         elif self.resource is not None:
-            request = PubSubRequest('discoInfo')
+            request = self._request_class('discoInfo')
             resource = self.resource.locateResource(request)
             d = resource.getNodes(requestor, target, nodeIdentifier)
         elif nodeIdentifier: