Changeset 202:645fbb5f02f4 for wokkel


Ignore:
Timestamp:
Oct 3, 2016, 8:49:10 AM (3 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
rebase_source:
e3c6719064011afeb728737f95959e1fa5e804ec
Message:

imported patch py3-pubsub.patch

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r166 r202  
    1111"""
    1212
    13 from zope.interface import implements
     13from __future__ import division, absolute_import
     14
     15from zope.interface import implementer
    1416
    1517from twisted.internet import defer
    1618from twisted.python import log
     19from twisted.python.compat import iteritems, unicode
    1720from twisted.words.protocols.jabber import jid, error
    1821from twisted.words.xish import domish
     
    104107
    105108    @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}
    108111
    109112    @ivar subscriber: The subscribing entity.
     
    112115    @ivar state: The subscription state. One of C{'subscribed'}, C{'pending'},
    113116                 C{'unconfigured'}.
    114     @type state: C{unicode}
     117    @type state: L{unicode}
    115118
    116119    @ivar options: Optional list of subscription options.
    117     @type options: C{dict}
     120    @type options: L{dict}
    118121
    119122    @ivar subscriptionIdentifier: Optional subscription identifier.
    120     @type subscriptionIdentifier: C{unicode}
     123    @type subscriptionIdentifier: L{unicode}
    121124    """
    122125
     
    169172        """
    170173        @param id: optional item identifier
    171         @type id: C{unicode}
     174        @type id: L{unicode}
    172175        @param payload: optional item payload. Either as a domish element, or
    173176                        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}.
    175178        """
    176179
     
    192195    The set of instance variables used depends on the type of request. If
    193196    a variable is not applicable or not passed in the request, its value is
    194     C{None}.
     197    L{None}.
    195198
    196199    @ivar verb: The type of publish-subscribe request. See C{_requestVerbMap}.
    197     @type verb: C{str}.
     200    @type verb: L{str}.
    198201
    199202    @ivar affiliations: Affiliations to be modified.
    200     @type affiliations: C{set}
     203    @type affiliations: L{set}
    201204
    202205    @ivar items: The items to be published, as L{domish.Element}s.
    203     @type items: C{list}
     206    @type items: L{list}
    204207
    205208    @ivar itemIdentifiers: Identifiers of the items to be retrieved or
    206209                           retracted.
    207     @type itemIdentifiers: C{set}
     210    @type itemIdentifiers: L{set}
    208211
    209212    @ivar maxItems: Maximum number of items to retrieve.
    210     @type maxItems: C{int}.
     213    @type maxItems: L{int}.
    211214
    212215    @ivar nodeIdentifier: Identifier of the node the request is about.
    213     @type nodeIdentifier: C{unicode}
     216    @type nodeIdentifier: L{unicode}
    214217
    215218    @ivar nodeType: The type of node that should be created, or for which the
    216219                    configuration is retrieved. C{'leaf'} or C{'collection'}.
    217     @type nodeType: C{str}
     220    @type nodeType: L{str}
    218221
    219222    @ivar options: Configurations options for nodes, subscriptions and publish
     
    225228
    226229    @ivar subscriptionIdentifier: Identifier for a specific subscription.
    227     @type subscriptionIdentifier: C{unicode}
     230    @type subscriptionIdentifier: L{unicode}
    228231
    229232    @ivar subscriptions: Subscriptions to be modified, as a set of
    230233        L{Subscription}.
    231     @type subscriptions: C{set}
     234    @type subscriptions: L{set}
    232235
    233236    @ivar affiliations: Affiliations to be modified, as a dictionary of entity
    234237        (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}
    237240    """
    238241
     
    275278
    276279    # 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)))
    278281
    279282    # Map request verb to parameter handler names
     
    646649    @type recipient: L{wokkel.pubsub.ItemsEvent}
    647650    @param nodeIdentifier: Identifier of the node the event pertains to.
    648     @type nodeIdentifier: C{unicode}
     651    @type nodeIdentifier: L{unicode}
    649652    @param headers: SHIM headers, see L{wokkel.shim.extractHeaders}.
    650     @type headers: C{dict}
     653    @type headers: L{dict}
    651654    """
    652655
     
    664667
    665668    @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}
    667670    """
    668671
     
    689692
    690693
     694@implementer(IPubSubClient)
    691695class PubSubClient(XMPPHandler):
    692696    """
    693697    Publish subscribe client protocol.
    694698    """
    695 
    696     implements(IPubSubClient)
    697699
    698700    def connectionInitialized(self):
     
    771773        @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
    772774        @param nodeIdentifier: Optional suggestion for the id of the node.
    773         @type nodeIdentifier: C{unicode}
     775        @type nodeIdentifier: L{unicode}
    774776        @param options: Optional node configuration options.
    775         @type options: C{dict}
     777        @type options: L{dict}
    776778        """
    777779        request = PubSubRequest('create')
     
    806808        @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
    807809        @param nodeIdentifier: The identifier of the node.
    808         @type nodeIdentifier: C{unicode}
     810        @type nodeIdentifier: L{unicode}
    809811        """
    810812        request = PubSubRequest('delete')
     
    824826
    825827        @param nodeIdentifier: The identifier of the node.
    826         @type nodeIdentifier: C{unicode}
     828        @type nodeIdentifier: L{unicode}
    827829
    828830        @param subscriber: The entity to subscribe to the node. This entity
     
    831833
    832834        @param options: Subscription options.
    833         @type options: C{dict}
     835        @type options: L{dict}
    834836
    835837        @return: Deferred that fires with L{Subscription} or errbacks with
     
    876878
    877879        @param nodeIdentifier: The identifier of the node.
    878         @type nodeIdentifier: C{unicode}
     880        @type nodeIdentifier: L{unicode}
    879881
    880882        @param subscriber: The entity to unsubscribe from the node.
     
    882884
    883885        @param subscriptionIdentifier: Optional subscription identifier.
    884         @type subscriptionIdentifier: C{unicode}
     886        @type subscriptionIdentifier: L{unicode}
    885887        """
    886888        request = PubSubRequest('unsubscribe')
     
    900902        @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
    901903        @param nodeIdentifier: The identifier of the node.
    902         @type nodeIdentifier: C{unicode}
     904        @type nodeIdentifier: L{unicode}
    903905        @param items: Optional list of L{Item}s to publish.
    904         @type items: C{list}
     906        @type items: L{list}
    905907        """
    906908        request = PubSubRequest('publish')
     
    921923
    922924        @param nodeIdentifier: The identifier of the node.
    923         @type nodeIdentifier: C{unicode}
     925        @type nodeIdentifier: L{unicode}
    924926
    925927        @param maxItems: Optional limit on the number of retrieved items.
    926         @type maxItems: C{int}
     928        @type maxItems: L{int}
    927929
    928930        @param subscriptionIdentifier: Optional subscription identifier. In
    929931            case the node has been subscribed to multiple times, this narrows
    930932            the results to the specific subscription.
    931         @type subscriptionIdentifier: C{unicode}
     933        @type subscriptionIdentifier: L{unicode}
    932934        """
    933935        request = PubSubRequest('items')
     
    960962
    961963        @param nodeIdentifier: The identifier of the node.
    962         @type nodeIdentifier: C{unicode}
     964        @type nodeIdentifier: L{unicode}
    963965
    964966        @param subscriber: The entity subscribed to the node.
     
    966968
    967969        @param subscriptionIdentifier: Optional subscription identifier.
    968         @type subscriptionIdentifier: C{unicode}
     970        @type subscriptionIdentifier: L{unicode}
    969971
    970972        @rtype: L{data_form.Form}
     
    997999
    9981000        @param nodeIdentifier: The identifier of the node.
    999         @type nodeIdentifier: C{unicode}
     1001        @type nodeIdentifier: L{unicode}
    10001002
    10011003        @param subscriber: The entity subscribed to the node.
     
    10031005
    10041006        @param options: Subscription options.
    1005         @type options: C{dict}.
     1007        @type options: L{dict}.
    10061008
    10071009        @param subscriptionIdentifier: Optional subscription identifier.
    1008         @type subscriptionIdentifier: C{unicode}
     1010        @type subscriptionIdentifier: L{unicode}
    10091011        """
    10101012        request = PubSubRequest('optionsSet')
     
    10251027
    10261028
     1029@implementer(IPubSubService, disco.IDisco)
    10271030class PubSubService(XMPPHandler, IQHandlerMixin):
    10281031    """
     
    10491052                         keys C{'category'}, C{'type'} and C{'name'}.
    10501053    @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    """
    10561057
    10571058    iqHandlers = {
     
    13521353            affiliations['node'] = request.nodeIdentifier
    13531354
    1354         for entity, affiliation in result.iteritems():
     1355        for entity, affiliation in iteritems(result):
    13551356            item = affiliations.addElement('affiliation')
    13561357            item['jid'] = entity.full()
     
    14511452
    14521453
     1454@implementer(IPubSubResource)
    14531455class PubSubResource(object):
    1454 
    1455     implements(IPubSubResource)
    14561456
    14571457    features = []
  • wokkel/test/test_pubsub.py

    r183 r202  
    55Tests for L{wokkel.pubsub}
    66"""
     7
     8from __future__ import division, absolute_import
    79
    810from zope.interface import verify
     
    29142916        def configureSet(request):
    29152917            self.assertEquals(['pubsub#deliver_payloads'],
    2916                               request.options.keys())
     2918                              list(request.options.keys()))
    29172919
    29182920        self.resource.getConfigurationOptions = getConfigurationOptions
Note: See TracChangeset for help on using the changeset viewer.