Changeset 202:645fbb5f02f4
- Timestamp:
- Oct 3, 2016, 8:49:10 AM (6 years ago)
- Branch:
- default
- rebase_source:
- e3c6719064011afeb728737f95959e1fa5e804ec
- Location:
- wokkel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/pubsub.py
r166 r202 11 11 """ 12 12 13 from zope.interface import implements 13 from __future__ import division, absolute_import 14 15 from zope.interface import implementer 14 16 15 17 from twisted.internet import defer 16 18 from twisted.python import log 19 from twisted.python.compat import iteritems, unicode 17 20 from twisted.words.protocols.jabber import jid, error 18 21 from twisted.words.xish import domish … … 104 107 105 108 @ivar nodeIdentifier: The identifier of the node subscribed to. The root 106 node is denoted by C{None}.107 @type nodeIdentifier: C{unicode}109 node is denoted by L{None}. 110 @type nodeIdentifier: L{unicode} 108 111 109 112 @ivar subscriber: The subscribing entity. … … 112 115 @ivar state: The subscription state. One of C{'subscribed'}, C{'pending'}, 113 116 C{'unconfigured'}. 114 @type state: C{unicode}117 @type state: L{unicode} 115 118 116 119 @ivar options: Optional list of subscription options. 117 @type options: C{dict}120 @type options: L{dict} 118 121 119 122 @ivar subscriptionIdentifier: Optional subscription identifier. 120 @type subscriptionIdentifier: C{unicode}123 @type subscriptionIdentifier: L{unicode} 121 124 """ 122 125 … … 169 172 """ 170 173 @param id: optional item identifier 171 @type id: C{unicode}174 @type id: L{unicode} 172 175 @param payload: optional item payload. Either as a domish element, or 173 176 as serialized XML. 174 @type payload: object providing L{domish.IElement} or C{unicode}.177 @type payload: object providing L{domish.IElement} or L{unicode}. 175 178 """ 176 179 … … 192 195 The set of instance variables used depends on the type of request. If 193 196 a variable is not applicable or not passed in the request, its value is 194 C{None}.197 L{None}. 195 198 196 199 @ivar verb: The type of publish-subscribe request. See C{_requestVerbMap}. 197 @type verb: C{str}.200 @type verb: L{str}. 198 201 199 202 @ivar affiliations: Affiliations to be modified. 200 @type affiliations: C{set}203 @type affiliations: L{set} 201 204 202 205 @ivar items: The items to be published, as L{domish.Element}s. 203 @type items: C{list}206 @type items: L{list} 204 207 205 208 @ivar itemIdentifiers: Identifiers of the items to be retrieved or 206 209 retracted. 207 @type itemIdentifiers: C{set}210 @type itemIdentifiers: L{set} 208 211 209 212 @ivar maxItems: Maximum number of items to retrieve. 210 @type maxItems: C{int}.213 @type maxItems: L{int}. 211 214 212 215 @ivar nodeIdentifier: Identifier of the node the request is about. 213 @type nodeIdentifier: C{unicode}216 @type nodeIdentifier: L{unicode} 214 217 215 218 @ivar nodeType: The type of node that should be created, or for which the 216 219 configuration is retrieved. C{'leaf'} or C{'collection'}. 217 @type nodeType: C{str}220 @type nodeType: L{str} 218 221 219 222 @ivar options: Configurations options for nodes, subscriptions and publish … … 225 228 226 229 @ivar subscriptionIdentifier: Identifier for a specific subscription. 227 @type subscriptionIdentifier: C{unicode}230 @type subscriptionIdentifier: L{unicode} 228 231 229 232 @ivar subscriptions: Subscriptions to be modified, as a set of 230 233 L{Subscription}. 231 @type subscriptions: C{set}234 @type subscriptions: L{set} 232 235 233 236 @ivar affiliations: Affiliations to be modified, as a dictionary of entity 234 237 (L{JID<twisted.words.protocols.jabber.jid.JID>} to affiliation 235 ( C{unicode}).236 @type affiliations: C{dict}238 (L{unicode}). 239 @type affiliations: L{dict} 237 240 """ 238 241 … … 275 278 276 279 # Map request verb to request iq type and subelement name 277 _verbRequestMap = dict(((v, k) for k, v in _requestVerbMap.iteritems()))280 _verbRequestMap = dict(((v, k) for k, v in iteritems(_requestVerbMap))) 278 281 279 282 # Map request verb to parameter handler names … … 646 649 @type recipient: L{wokkel.pubsub.ItemsEvent} 647 650 @param nodeIdentifier: Identifier of the node the event pertains to. 648 @type nodeIdentifier: C{unicode}651 @type nodeIdentifier: L{unicode} 649 652 @param headers: SHIM headers, see L{wokkel.shim.extractHeaders}. 650 @type headers: C{dict}653 @type headers: L{dict} 651 654 """ 652 655 … … 664 667 665 668 @param items: List of received items as domish elements. 666 @type items: C{list} of L{domish.Element}669 @type items: L{list} of L{domish.Element} 667 670 """ 668 671 … … 689 692 690 693 694 @implementer(IPubSubClient) 691 695 class PubSubClient(XMPPHandler): 692 696 """ 693 697 Publish subscribe client protocol. 694 698 """ 695 696 implements(IPubSubClient)697 699 698 700 def connectionInitialized(self): … … 771 773 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>} 772 774 @param nodeIdentifier: Optional suggestion for the id of the node. 773 @type nodeIdentifier: C{unicode}775 @type nodeIdentifier: L{unicode} 774 776 @param options: Optional node configuration options. 775 @type options: C{dict}777 @type options: L{dict} 776 778 """ 777 779 request = PubSubRequest('create') … … 806 808 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>} 807 809 @param nodeIdentifier: The identifier of the node. 808 @type nodeIdentifier: C{unicode}810 @type nodeIdentifier: L{unicode} 809 811 """ 810 812 request = PubSubRequest('delete') … … 824 826 825 827 @param nodeIdentifier: The identifier of the node. 826 @type nodeIdentifier: C{unicode}828 @type nodeIdentifier: L{unicode} 827 829 828 830 @param subscriber: The entity to subscribe to the node. This entity … … 831 833 832 834 @param options: Subscription options. 833 @type options: C{dict}835 @type options: L{dict} 834 836 835 837 @return: Deferred that fires with L{Subscription} or errbacks with … … 876 878 877 879 @param nodeIdentifier: The identifier of the node. 878 @type nodeIdentifier: C{unicode}880 @type nodeIdentifier: L{unicode} 879 881 880 882 @param subscriber: The entity to unsubscribe from the node. … … 882 884 883 885 @param subscriptionIdentifier: Optional subscription identifier. 884 @type subscriptionIdentifier: C{unicode}886 @type subscriptionIdentifier: L{unicode} 885 887 """ 886 888 request = PubSubRequest('unsubscribe') … … 900 902 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>} 901 903 @param nodeIdentifier: The identifier of the node. 902 @type nodeIdentifier: C{unicode}904 @type nodeIdentifier: L{unicode} 903 905 @param items: Optional list of L{Item}s to publish. 904 @type items: C{list}906 @type items: L{list} 905 907 """ 906 908 request = PubSubRequest('publish') … … 921 923 922 924 @param nodeIdentifier: The identifier of the node. 923 @type nodeIdentifier: C{unicode}925 @type nodeIdentifier: L{unicode} 924 926 925 927 @param maxItems: Optional limit on the number of retrieved items. 926 @type maxItems: C{int}928 @type maxItems: L{int} 927 929 928 930 @param subscriptionIdentifier: Optional subscription identifier. In 929 931 case the node has been subscribed to multiple times, this narrows 930 932 the results to the specific subscription. 931 @type subscriptionIdentifier: C{unicode}933 @type subscriptionIdentifier: L{unicode} 932 934 """ 933 935 request = PubSubRequest('items') … … 960 962 961 963 @param nodeIdentifier: The identifier of the node. 962 @type nodeIdentifier: C{unicode}964 @type nodeIdentifier: L{unicode} 963 965 964 966 @param subscriber: The entity subscribed to the node. … … 966 968 967 969 @param subscriptionIdentifier: Optional subscription identifier. 968 @type subscriptionIdentifier: C{unicode}970 @type subscriptionIdentifier: L{unicode} 969 971 970 972 @rtype: L{data_form.Form} … … 997 999 998 1000 @param nodeIdentifier: The identifier of the node. 999 @type nodeIdentifier: C{unicode}1001 @type nodeIdentifier: L{unicode} 1000 1002 1001 1003 @param subscriber: The entity subscribed to the node. … … 1003 1005 1004 1006 @param options: Subscription options. 1005 @type options: C{dict}.1007 @type options: L{dict}. 1006 1008 1007 1009 @param subscriptionIdentifier: Optional subscription identifier. 1008 @type subscriptionIdentifier: C{unicode}1010 @type subscriptionIdentifier: L{unicode} 1009 1011 """ 1010 1012 request = PubSubRequest('optionsSet') … … 1025 1027 1026 1028 1029 @implementer(IPubSubService, disco.IDisco) 1027 1030 class PubSubService(XMPPHandler, IQHandlerMixin): 1028 1031 """ … … 1049 1052 keys C{'category'}, C{'type'} and C{'name'}. 1050 1053 @ivar pubSubFeatures: List of supported publish-subscribe features for 1051 service discovery, as C{str}. 1052 @type pubSubFeatures: C{list} or C{None} 1053 """ 1054 1055 implements(IPubSubService, disco.IDisco) 1054 service discovery, as L{str}. 1055 @type pubSubFeatures: L{list} or L{None} 1056 """ 1056 1057 1057 1058 iqHandlers = { … … 1352 1353 affiliations['node'] = request.nodeIdentifier 1353 1354 1354 for entity, affiliation in result.iteritems():1355 for entity, affiliation in iteritems(result): 1355 1356 item = affiliations.addElement('affiliation') 1356 1357 item['jid'] = entity.full() … … 1451 1452 1452 1453 1454 @implementer(IPubSubResource) 1453 1455 class PubSubResource(object): 1454 1455 implements(IPubSubResource)1456 1456 1457 1457 features = [] -
wokkel/test/test_pubsub.py
r183 r202 5 5 Tests for L{wokkel.pubsub} 6 6 """ 7 8 from __future__ import division, absolute_import 7 9 8 10 from zope.interface import verify … … 2914 2916 def configureSet(request): 2915 2917 self.assertEquals(['pubsub#deliver_payloads'], 2916 request.options.keys())2918 list(request.options.keys())) 2917 2919 2918 2920 self.resource.getConfigurationOptions = getConfigurationOptions
Note: See TracChangeset
for help on using the changeset viewer.