source: ralphm-patches/pubsub_resource.patch @ 4:c8c73d9e5496

Last change on this file since 4:c8c73d9e5496 was 4:c8c73d9e5496, checked in by Ralph Meijer <ralphm@…>, 12 years ago

Save bunch of work.

File size: 31.7 KB
  • wokkel/iwokkel.py

    diff -r dc8ed1ff55d7 wokkel/iwokkel.py
    a b  
    297297        """
    298298
    299299
    300     def publish(request):
     300class IPubSubResource(Interface):
     301
     302    def locateResource(request):
    301303        """
    302         Called when a publish request has been received.
     304        Locate a resource that will handle the request.
    303305
    304306        @param request: The publish-subscribe request.
    305307        @type request: L{wokkel.pubsub.PubSubRequest}
    306         @return: deferred that fires on success.
    307         @rtype: L{defer.Deferred}
    308         """
    309 
    310 
    311     def subscribe(request):
    312         """
    313         Called when a subscribe request has been received.
    314 
    315         @param request: The publish-subscribe request.
    316         @type request: L{wokkel.pubsub.PubSubRequest}
    317         @return: A deferred that fires with a
    318                  L{Subscription<wokkel.pubsub.Subscription>}.
    319         @rtype: L{defer.Deferred}
    320         """
    321 
    322 
    323     def unsubscribe(request):
    324         """
    325         Called when a subscribe request has been received.
    326 
    327         @param request: The publish-subscribe request.
    328         @type request: L{wokkel.pubsub.PubSubRequest}
    329         @return: A deferred that fires with C{None} when unsubscription has
    330                  succeeded.
    331         @rtype: L{defer.Deferred}
    332         """
    333 
    334 
    335     def subscriptions(request):
    336         """
    337         Called when a subscriptions retrieval request has been received.
    338 
    339         @param request: The publish-subscribe request.
    340         @type request: L{wokkel.pubsub.PubSubRequest}
    341         @return: A deferred that fires with a C{list} of subscriptions as
    342                  L{Subscription<wokkel.pubsub.Subscription>}.
    343         @rtype: L{defer.Deferred}
    344         """
    345 
    346 
    347     def affiliations(request):
    348         """
    349         Called when a affiliations retrieval request has been received.
    350 
    351         @param request: The publish-subscribe request.
    352         @type request: L{wokkel.pubsub.PubSubRequest}
    353         @return: A deferred that fires with a C{list} of affiliations as
    354                  C{tuple}s of (node identifier as C{unicode}, affiliation state
    355                  as C{str}). The affiliation can be C{'owner'}, C{'publisher'},
    356                  or C{'outcast'}.
    357         @rtype: L{defer.Deferred}
    358         """
    359 
    360 
    361     def create(request):
    362         """
    363         Called when a node creation request has been received.
    364 
    365         @param request: The publish-subscribe request.
    366         @type request: L{wokkel.pubsub.PubSubRequest}
    367         @return: A deferred that fires with a C{unicode} that represents
    368                  the identifier of the new node.
    369         @rtype: L{defer.Deferred}
    370308        """
    371309
    372310
     
    406344        """
    407345
    408346
    409     def getDefaultConfiguration(request):
     347    def pubsub_publish(request):
     348        """
     349        Called when a publish request has been received.
     350
     351        @param request: The publish-subscribe request.
     352        @type request: L{wokkel.pubsub.PubSubRequest}
     353        @return: deferred that fires on success.
     354        @rtype: L{defer.Deferred}
     355        """
     356
     357
     358    def pubsub_subscribe(request):
     359        """
     360        Called when a subscribe request has been received.
     361
     362        @param request: The publish-subscribe request.
     363        @type request: L{wokkel.pubsub.PubSubRequest}
     364        @return: A deferred that fires with a
     365                 L{Subscription<wokkel.pubsub.Subscription>}.
     366        @rtype: L{defer.Deferred}
     367        """
     368
     369
     370    def pubsub_unsubscribe(request):
     371        """
     372        Called when a subscribe request has been received.
     373
     374        @param request: The publish-subscribe request.
     375        @type request: L{wokkel.pubsub.PubSubRequest}
     376        @return: A deferred that fires with C{None} when unsubscription has
     377                 succeeded.
     378        @rtype: L{defer.Deferred}
     379        """
     380
     381
     382    def pubsub_subscriptions(request):
     383        """
     384        Called when a subscriptions retrieval request has been received.
     385
     386        @param request: The publish-subscribe request.
     387        @type request: L{wokkel.pubsub.PubSubRequest}
     388        @return: A deferred that fires with a C{list} of subscriptions as
     389                 L{Subscription<wokkel.pubsub.Subscription>}.
     390        @rtype: L{defer.Deferred}
     391        """
     392
     393
     394    def pubsub_affiliations(request):
     395        """
     396        Called when a affiliations retrieval request has been received.
     397
     398        @param request: The publish-subscribe request.
     399        @type request: L{wokkel.pubsub.PubSubRequest}
     400        @return: A deferred that fires with a C{list} of affiliations as
     401                 C{tuple}s of (node identifier as C{unicode}, affiliation state
     402                 as C{str}). The affiliation can be C{'owner'}, C{'publisher'},
     403                 or C{'outcast'}.
     404        @rtype: L{defer.Deferred}
     405        """
     406
     407
     408    def pubsub_create(request):
     409        """
     410        Called when a node creation request has been received.
     411
     412        @param request: The publish-subscribe request.
     413        @type request: L{wokkel.pubsub.PubSubRequest}
     414        @return: A deferred that fires with a C{unicode} that represents
     415                 the identifier of the new node.
     416        @rtype: L{defer.Deferred}
     417        """
     418
     419
     420    def pubsub_default(request):
    410421        """
    411422        Called when a default node configuration request has been received.
    412423
     
    420431        """
    421432
    422433
    423     def getConfiguration(request):
     434    def pubsub_configureGet(request):
    424435        """
    425436        Called when a node configuration retrieval request has been received.
    426437
     
    433444        """
    434445
    435446
    436     def setConfiguration(request):
     447    def pubsub_configureSet(request):
    437448        """
    438449        Called when a node configuration change request has been received.
    439450
     
    445456        """
    446457
    447458
    448     def items(request):
     459    def pubsub_items(request):
    449460        """
    450461        Called when a items retrieval request has been received.
    451462
     
    456467        """
    457468
    458469
    459     def retract(request):
     470    def pubsub_retract(request):
    460471        """
    461472        Called when a item retraction request has been received.
    462473
     
    468479        """
    469480
    470481
    471     def purge(request):
     482    def pubsub_purge(request):
    472483        """
    473484        Called when a node purge request has been received.
    474485
     
    480491        """
    481492
    482493
    483     def delete(request):
     494    def pubsub_delete(request):
    484495        """
    485496        Called when a node deletion request has been received.
    486497
  • wokkel/pubsub.py

    diff -r dc8ed1ff55d7 wokkel/pubsub.py
    a b  
    1818
    1919from wokkel import disco, data_form, generic, shim
    2020from wokkel.subprotocols import IQHandlerMixin, XMPPHandler
    21 from wokkel.iwokkel import IPubSubClient, IPubSubService
     21from wokkel.iwokkel import IPubSubClient, IPubSubService, IPubSubResource
    2222
    2323# Iq get and set XPath queries
    2424IQ_GET = '/iq[@type="get"]'
     
    7777
    7878class Unsupported(PubSubError):
    7979    def __init__(self, feature, text=None):
     80        self.feature = feature
    8081        PubSubError.__init__(self, 'feature-not-implemented',
    8182                                   'unsupported',
    8283                                   feature,
    8384                                   text)
    8485
     86    def __str__(self):
     87        message = PubSubError.__str__(self)
     88        message += ', feature %r' % self.feature
     89        return message
    8590
    8691
    8792class Subscription(object):
     
    228233        'retract': ['node', 'itemIdentifiers'],
    229234        'purge': ['node'],
    230235        'delete': ['node'],
    231         'affiliationsGet': [],
     236        'affiliationsGet': ['nodeOrEmpty'],
    232237        'affiliationsSet': [],
    233         'subscriptionsGet': [],
     238        'subscriptionsGet': ['nodeOrEmpty'],
    234239        'subscriptionsSet': [],
    235240    }
    236241
     
    359364        else:
    360365            self.nodeType = 'leaf'
    361366
     367        if self.nodeType not in ('leaf', 'collection'):
     368            raise error.StanzaError('not-acceptable')
     369
    362370
    363371    def _parse_configure(self, verbElement):
    364372        """
     
    787795            '/*': '_onPubSubRequest',
    788796            }
    789797
    790 
    791     def __init__(self):
     798    def __init__(self, resource):
     799        self.resource = resource
    792800        self.discoIdentity = {'category': 'pubsub',
    793801                              'type': 'generic',
    794802                              'name': 'Generic Publish-Subscribe Service'}
     
    851859
    852860    def _onPubSubRequest(self, iq):
    853861        request = PubSubRequest.fromElement(iq)
    854         handler = getattr(self, '_on_%s' % request.verb)
    855         return handler(request)
     862        resource = self.resource.locateResource(request)
    856863
     864        # Preprocess the request, knowing the handling resource
     865        try:
     866            preProcessor = getattr(self, '_preProcess_%s' % request.verb)
     867        except AttributeError:
     868            pass
     869        else:
     870            request = preProcessor(resource, request)
     871            if request is None:
     872                return defer.succeed(None)
    857873
    858     def _on_publish(self, request):
    859         return self.publish(request)
     874        # Process the request itself,
     875        try:
     876            handler = getattr(resource, 'pubsub_%s' % request.verb)
     877        except AttributeError:
     878            # fix lookup feature
     879            text = "Request verb: %s" % request.verb
     880            return defer.fail(Unsupported('', text))
    860881
     882        d = handler(request)
    861883
    862     def _on_subscribe(self, request):
     884        # If needed, translate the result into a response
     885        try:
     886            cb = getattr(self, '_toResponse_%s' % request.verb)
     887        except AttributeError:
     888            pass
     889        else:
     890            d.addCallback(cb, resource, request)
    863891
    864         def toResponse(result):
    865             response = domish.Element((NS_PUBSUB, "pubsub"))
    866             subscription = response.addElement("subscription")
    867             if result.nodeIdentifier:
    868                 subscription["node"] = result.nodeIdentifier
    869             subscription["jid"] = result.subscriber.full()
    870             subscription["subscription"] = result.state
    871             return response
    872 
    873         d = self.subscribe(request)
    874         d.addCallback(toResponse)
    875892        return d
    876893
    877894
    878     def _on_unsubscribe(self, request):
    879         return self.unsubscribe(request)
     895    def _toResponse_subscribe(self, result, resource, request):
     896        response = domish.Element((NS_PUBSUB, "pubsub"))
     897        subscription = response.addElement("subscription")
     898        if result.nodeIdentifier:
     899            subscription["node"] = result.nodeIdentifier
     900        subscription["jid"] = result.subscriber.full()
     901        subscription["subscription"] = result.state
     902        return response
    880903
    881904
    882     def _on_optionsGet(self, request):
    883         raise Unsupported('subscription-options')
     905    def _toResponse_subscriptions(self, result, resource, request):
     906        response = domish.Element((NS_PUBSUB, 'pubsub'))
     907        subscriptions = response.addElement('subscriptions')
     908        for subscription in result:
     909            item = subscriptions.addElement('subscription')
     910            item['node'] = subscription.nodeIdentifier
     911            item['jid'] = subscription.subscriber.full()
     912            item['subscription'] = subscription.state
     913        return response
    884914
    885915
    886     def _on_optionsSet(self, request):
    887         raise Unsupported('subscription-options')
     916    def _toResponse_affiliations(self, result, resource, request):
     917        response = domish.Element((NS_PUBSUB, 'pubsub'))
     918        affiliations = response.addElement('affiliations')
    888919
     920        for nodeIdentifier, affiliation in result:
     921            item = affiliations.addElement('affiliation')
     922            item['node'] = nodeIdentifier
     923            item['affiliation'] = affiliation
    889924
    890     def _on_subscriptions(self, request):
     925        return response
    891926
    892         def toResponse(result):
     927
     928    def _toResponse_create(self, result, resource, request):
     929        if not request.nodeIdentifier or request.nodeIdentifier != result:
    893930            response = domish.Element((NS_PUBSUB, 'pubsub'))
    894             subscriptions = response.addElement('subscriptions')
    895             for subscription in result:
    896                 item = subscriptions.addElement('subscription')
    897                 item['node'] = subscription.nodeIdentifier
    898                 item['jid'] = subscription.subscriber.full()
    899                 item['subscription'] = subscription.state
     931            create = response.addElement('create')
     932            create['node'] = result
    900933            return response
    901 
    902         d = self.subscriptions(request)
    903         d.addCallback(toResponse)
    904         return d
    905 
    906 
    907     def _on_affiliations(self, request):
    908 
    909         def toResponse(result):
    910             response = domish.Element((NS_PUBSUB, 'pubsub'))
    911             affiliations = response.addElement('affiliations')
    912 
    913             for nodeIdentifier, affiliation in result:
    914                 item = affiliations.addElement('affiliation')
    915                 item['node'] = nodeIdentifier
    916                 item['affiliation'] = affiliation
    917 
    918             return response
    919 
    920         d = self.affiliations(request)
    921         d.addCallback(toResponse)
    922         return d
    923 
    924 
    925     def _on_create(self, request):
    926 
    927         def toResponse(result):
    928             if not request.nodeIdentifier or request.nodeIdentifier != result:
    929                 response = domish.Element((NS_PUBSUB, 'pubsub'))
    930                 create = response.addElement('create')
    931                 create['node'] = result
    932                 return response
    933             else:
    934                 return None
    935 
    936         d = self.create(request)
    937         d.addCallback(toResponse)
    938         return d
     934        else:
     935            return None
    939936
    940937
    941938    def _makeFields(self, options, values):
     
    954951        return fields
    955952
    956953
    957     def _formFromConfiguration(self, values):
    958         options = self.getConfigurationOptions()
     954    def _formFromConfiguration(self, resource, values):
     955        options = resource.getConfigurationOptions()
    959956        fields = self._makeFields(options, values)
    960957        form = data_form.Form(formType="form",
    961958                              formNamespace=NS_PUBSUB_NODE_CONFIG,
     
    964961        return form
    965962
    966963
    967     def _checkConfiguration(self, values):
    968         options = self.getConfigurationOptions()
     964    def _checkConfiguration(self, resource, values):
     965        options = resource.getConfigurationOptions()
    969966        processedValues = {}
    970967
    971968        for key, value in values.iteritems():
     
    989986        return processedValues
    990987
    991988
    992     def _on_default(self, request):
     989    def _toResponse_default(self, options, resource, request):
     990        response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
     991        default = response.addElement("default")
     992        form = self._formFromConfiguration(resource, options)
     993        default.addChild(form.toElement())
     994        return response
    993995
    994         def toResponse(options):
    995             response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
    996             default = response.addElement("default")
    997             default.addChild(self._formFromConfiguration(options).toElement())
    998             return response
    999996
    1000         if request.nodeType not in ('leaf', 'collection'):
    1001             return defer.fail(error.StanzaError('not-acceptable'))
     997    def _toResponse_configureGet(self, options, resource, request):
     998        response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
     999        configure = response.addElement("configure")
     1000        form = self._formFromConfiguration(resource, options)
     1001        configure.addChild(form.toElement())
    10021002
    1003         d = self.getDefaultConfiguration(request)
    1004         d.addCallback(toResponse)
    1005         return d
     1003        if request.nodeIdentifier:
     1004            configure["node"] = request.nodeIdentifier
    10061005
     1006        return response
    10071007
    1008     def _on_configureGet(self, request):
    1009         def toResponse(options):
    1010             response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
    1011             configure = response.addElement("configure")
    1012             form = self._formFromConfiguration(options)
    1013             configure.addChild(form.toElement())
    10141008
    1015             if request.nodeIdentifier:
    1016                 configure["node"] = request.nodeIdentifier
    1017 
    1018             return response
    1019 
    1020         d = self.getConfiguration(request)
    1021         d.addCallback(toResponse)
    1022         return d
    1023 
    1024 
    1025     def _on_configureSet(self, request):
     1009    def _preProcess_configureSet(self, resource, request):
    10261010        if request.options:
    1027             request.options = self._checkConfiguration(request.options)
    1028             return self.setConfiguration(request)
     1011            request.options = self._checkConfiguration(resource,
     1012                                                       request.options)
     1013            return request
    10291014        else:
    10301015            return None
    10311016
    10321017
     1018    def _toResponse_items(self, result, resource, request):
     1019        response = domish.Element((NS_PUBSUB, 'pubsub'))
     1020        items = response.addElement('items')
     1021        items["node"] = request.nodeIdentifier
    10331022
    1034     def _on_items(self, request):
     1023        for item in result:
     1024            items.addChild(item)
    10351025
    1036         def toResponse(result):
    1037             response = domish.Element((NS_PUBSUB, 'pubsub'))
    1038             items = response.addElement('items')
    1039             items["node"] = request.nodeIdentifier
     1026        return response
    10401027
    1041             for item in result:
    1042                 items.addChild(item)
    1043 
    1044             return response
    1045 
    1046         d = self.items(request)
    1047         d.addCallback(toResponse)
    1048         return d
    1049 
    1050 
    1051     def _on_retract(self, request):
    1052         return self.retract(request)
    1053 
    1054 
    1055     def _on_purge(self, request):
    1056         return self.purge(request)
    1057 
    1058 
    1059     def _on_delete(self, request):
    1060         return self.delete(request)
    1061 
    1062 
    1063     def _on_affiliationsGet(self, iq):
    1064         raise Unsupported('modify-affiliations')
    1065 
    1066 
    1067     def _on_affiliationsSet(self, iq):
    1068         raise Unsupported('modify-affiliations')
    1069 
    1070 
    1071     def _on_subscriptionsGet(self, iq):
    1072         raise Unsupported('manage-subscriptions')
    1073 
    1074 
    1075     def _on_subscriptionsSet(self, iq):
    1076         raise Unsupported('manage-subscriptions')
    1077 
    1078     # public methods
    10791028
    10801029    def _createNotification(self, eventType, service, nodeIdentifier,
    10811030                                  subscriber, subscriptions=None):
     
    10991048
    11001049        return message
    11011050
     1051    # public methods
     1052
    11021053    def notifyPublish(self, service, nodeIdentifier, notifications):
    11031054        for subscriber, subscriptions, items in notifications:
    11041055            message = self._createNotification('items', service,
     
    11201071            self.send(message)
    11211072
    11221073
    1123     def getNodeInfo(self, requestor, service, nodeIdentifier):
    1124         return None
     1074
     1075class PubSubResource(object):
     1076
     1077    implements(IPubSubResource)
     1078
     1079    def locateResource(self, request):
     1080        return self
     1081
     1082
     1083    def getInfo(self, requestor, service, nodeIdentifier):
     1084        return defer.succeed(None)
    11251085
    11261086
    11271087    def getNodes(self, requestor, service):
    11281088        return []
    11291089
    11301090
    1131     def publish(self, request):
    1132         raise Unsupported('publish')
    1133 
    1134 
    1135     def subscribe(self, request):
    1136         raise Unsupported('subscribe')
    1137 
    1138 
    1139     def unsubscribe(self, request):
    1140         raise Unsupported('subscribe')
    1141 
    1142 
    1143     def subscriptions(self, request):
    1144         raise Unsupported('retrieve-subscriptions')
    1145 
    1146 
    1147     def affiliations(self, request):
    1148         raise Unsupported('retrieve-affiliations')
    1149 
    1150 
    1151     def create(self, request):
    1152         raise Unsupported('create-nodes')
    1153 
    1154 
    11551091    def getConfigurationOptions(self):
    11561092        return {}
    11571093
    11581094
    1159     def getDefaultConfiguration(self, request):
    1160         raise Unsupported('retrieve-default')
     1095    def pubsub_publish(self, request):
     1096        return defer.fail(Unsupported('publish'))
    11611097
    11621098
    1163     def getConfiguration(self, request):
    1164         raise Unsupported('config-node')
     1099    def pubsub_subscribe(self, request):
     1100        return defer.fail(Unsupported('subscribe'))
    11651101
    11661102
    1167     def setConfiguration(self, request):
    1168         raise Unsupported('config-node')
     1103    def pubsub_unsubscribe(self, request):
     1104        return defer.fail(Unsupported('subscribe'))
    11691105
    11701106
    1171     def items(self, request):
    1172         raise Unsupported('retrieve-items')
     1107    def pubsub_subscriptions(self, request):
     1108        return defer.fail(Unsupported('retrieve-subscriptions'))
    11731109
    11741110
    1175     def retract(self, request):
    1176         raise Unsupported('retract-items')
     1111    def pubsub_affiliations(self, request):
     1112        return defer.fail(Unsupported('retrieve-affiliations'))
    11771113
    11781114
    1179     def purge(self, request):
    1180         raise Unsupported('purge-nodes')
     1115    def pubsub_create(self, request):
     1116        return defer.fail(Unsupported('create-nodes'))
    11811117
    11821118
    1183     def delete(self, request):
    1184         raise Unsupported('delete-nodes')
     1119    def pubsub_default(self, request):
     1120        return defer.fail(Unsupported('retrieve-default'))
     1121
     1122
     1123    def pubsub_configureGet(self, request):
     1124        return defer.fail(Unsupported('config-node'))
     1125
     1126
     1127    def pubsub_configureSet(self, request):
     1128        return defer.fail(Unsupported('config-node'))
     1129
     1130
     1131    def pubsub_items(self, request):
     1132        return defer.fail(Unsupported('retrieve-items'))
     1133
     1134
     1135    def pubsub_retract(self, request):
     1136        return defer.fail(Unsupported('retract-items'))
     1137
     1138
     1139    def pubsub_purge(self, request):
     1140        return defer.fail(Unsupported('purge-nodes'))
     1141
     1142
     1143    def pubsub_delete(self, request):
     1144        return defer.fail(Unsupported('delete-nodes'))
     1145
     1146
     1147    def pubsub_affiliationsGet(self, request):
     1148        return defer.fail(Unsupported('modify-affiliations'))
     1149
     1150
     1151    def pubsub_affiliationsSet(self, request):
     1152        return defer.fail(Unsupported('modify-affiliations'))
     1153
     1154
     1155    def pubsub_subscriptionsGet(self, request):
     1156        return defer.fail(Unsupported('manage-subscriptions'))
     1157
     1158
     1159    def pubsub_subscriptionsSet(self, request):
     1160        return defer.fail(Unsupported('manage-subscriptions'))
  • wokkel/test/test_pubsub.py

    diff -r dc8ed1ff55d7 wokkel/test/test_pubsub.py
    a b  
    600600
    601601    def setUp(self):
    602602        self.stub = XmlStreamStub()
    603         self.service = pubsub.PubSubService()
     603        self.resource = pubsub.PubSubResource()
     604        self.service = pubsub.PubSubService(self.resource)
    604605        self.service.send = self.stub.xmlstream.send
    605606
    606607    def test_interface(self):
     
    694695            self.assertEqual([], request.items)
    695696            return defer.succeed(None)
    696697
    697         self.service.publish = publish
    698         verify.verifyObject(iwokkel.IPubSubService, self.service)
     698        self.resource.pubsub_publish = publish
     699        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    699700        return self.handleRequest(xml)
    700701
    701702
     
    722723            self.assertEqual(u'item2', request.items[1]["id"])
    723724            return defer.succeed(None)
    724725
    725         self.service.publish = publish
    726         verify.verifyObject(iwokkel.IPubSubService, self.service)
     726        self.resource.pubsub_publish = publish
     727        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    727728        return self.handleRequest(xml)
    728729
    729730
     
    759760            self.assertEqual('user@example.org/Home', subscription['jid'])
    760761            self.assertEqual('subscribed', subscription['subscription'])
    761762
    762         self.service.subscribe = subscribe
    763         verify.verifyObject(iwokkel.IPubSubService, self.service)
     763        self.resource.pubsub_subscribe = subscribe
     764        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    764765        d = self.handleRequest(xml)
    765766        d.addCallback(cb)
    766767        return d
     
    789790        def cb(element):
    790791            self.assertFalse(element.subscription.hasAttribute('node'))
    791792
    792         self.service.subscribe = subscribe
    793         verify.verifyObject(iwokkel.IPubSubService, self.service)
     793        self.resource.pubsub_subscribe = subscribe
     794        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    794795        d = self.handleRequest(xml)
    795796        d.addCallback(cb)
    796797        return d
     
    820821        def cb(element):
    821822            self.assertIdentical(None, element)
    822823
    823         self.service.unsubscribe = unsubscribe
    824         verify.verifyObject(iwokkel.IPubSubService, self.service)
     824        self.resource.pubsub_unsubscribe = unsubscribe
     825        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    825826        d = self.handleRequest(xml)
    826827        d.addCallback(cb)
    827828        return d
     
    914915                                               'subscribed')
    915916            return defer.succeed([subscription])
    916917
    917         self.service.subscriptions = subscriptions
    918         verify.verifyObject(iwokkel.IPubSubService, self.service)
     918        self.resource.pubsub_subscriptions = subscriptions
     919        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    919920        d = self.handleRequest(xml)
    920921        d.addCallback(cb)
    921922        return d
     
    956957            affiliation = ('test', 'owner')
    957958            return defer.succeed([affiliation])
    958959
    959         self.service.affiliations = affiliations
    960         verify.verifyObject(iwokkel.IPubSubService, self.service)
     960        self.resource.pubsub_affiliations = affiliations
     961        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    961962        d = self.handleRequest(xml)
    962963        d.addCallback(cb)
    963964        return d
     
    986987        def cb(element):
    987988            self.assertIdentical(None, element)
    988989
    989         self.service.create = create
    990         verify.verifyObject(iwokkel.IPubSubService, self.service)
     990        self.resource.pubsub_create = create
     991        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    991992        d = self.handleRequest(xml)
    992993        d.addCallback(cb)
    993994        return d
     
    10171018            self.assertEqual(u'myrenamednode',
    10181019                             element.create.getAttribute('node'))
    10191020
    1020         self.service.create = create
    1021         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1021        self.resource.pubsub_create = create
     1022        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    10221023        d = self.handleRequest(xml)
    10231024        d.addCallback(cb)
    10241025        return d
     
    10481049            self.assertEqual(NS_PUBSUB, element.create.uri)
    10491050            self.assertEqual(u'random', element.create.getAttribute('node'))
    10501051
    1051         self.service.create = create
    1052         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1052        self.resource.pubsub_create = create
     1053        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    10531054        d = self.handleRequest(xml)
    10541055        d.addCallback(cb)
    10551056        return d
     
    10931094            form = data_form.Form.fromElement(element.default.x)
    10941095            self.assertEqual(NS_PUBSUB_CONFIG, form.formNamespace)
    10951096
    1096         self.service.getConfigurationOptions = getConfigurationOptions
    1097         self.service.getDefaultConfiguration = getDefaultConfiguration
    1098         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1097        self.resource.getConfigurationOptions = getConfigurationOptions
     1098        self.resource.pubsub_default = getDefaultConfiguration
     1099        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    10991100        d = self.handleRequest(xml)
    11001101        d.addCallback(cb)
    11011102        return d
     
    11431144            form = data_form.Form.fromElement(element.default.x)
    11441145            self.assertEqual(NS_PUBSUB_CONFIG, form.formNamespace)
    11451146
    1146         self.service.getConfigurationOptions = getConfigurationOptions
    1147         self.service.getDefaultConfiguration = getDefaultConfiguration
    1148         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1147        self.resource.getConfigurationOptions = getConfigurationOptions
     1148        self.resource.pubsub_default = getDefaultConfiguration
     1149        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    11491150        d = self.handleRequest(xml)
    11501151        d.addCallback(cb)
    11511152        return d
     
    11821183        def cb(result):
    11831184            self.assertEquals('not-acceptable', result.condition)
    11841185
    1185         self.service.getDefaultConfiguration = getDefaultConfiguration
    1186         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1186        self.resource.pubsub_default = getDefaultConfiguration
     1187        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    11871188        d = self.handleRequest(xml)
    11881189        self.assertFailure(d, error.StanzaError)
    11891190        d.addCallback(cb)
     
    12571258            self.assertNotIn('x-myfield', fields)
    12581259
    12591260
    1260         self.service.getConfigurationOptions = getConfigurationOptions
    1261         self.service.getConfiguration = getConfiguration
    1262         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1261        self.resource.getConfigurationOptions = getConfigurationOptions
     1262        self.resource.pubsub_configureGet = getConfiguration
     1263        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    12631264        d = self.handleRequest(xml)
    12641265        d.addCallback(cb)
    12651266        return d
     
    13061307                              'pubsub#persist_items': True}, request.options)
    13071308            return defer.succeed(None)
    13081309
    1309         self.service.getConfigurationOptions = getConfigurationOptions
    1310         self.service.setConfiguration = setConfiguration
    1311         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1310        self.resource.getConfigurationOptions = getConfigurationOptions
     1311        self.resource.pubsub_configureSet = setConfiguration
     1312        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    13121313        return self.handleRequest(xml)
    13131314
    13141315
     
    13361337        def setConfiguration(request):
    13371338            self.fail("Unexpected call to setConfiguration")
    13381339
    1339         self.service.setConfiguration = setConfiguration
    1340         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1340        self.resource.pubsub_configureSet = setConfiguration
     1341        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    13411342        return self.handleRequest(xml)
    13421343
    13431344
     
    13771378            self.assertEquals(['pubsub#deliver_payloads'],
    13781379                              request.options.keys())
    13791380
    1380         self.service.getConfigurationOptions = getConfigurationOptions
    1381         self.service.setConfiguration = setConfiguration
    1382         verify.verifyObject(iwokkel.IPubSubService, self.service)
     1381        self.resource.getConfigurationOptions = getConfigurationOptions
     1382        self.resource.pubsub_configureSet = setConfiguration
     1383        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    13831384        return self.handleRequest(xml)
    13841385
    13851386
     
    14451446            self.assertEqual(NS_PUBSUB, item.uri)
    14461447            self.assertEqual('current', item['id'])
    14471448
    1448         self.service.items = items
     1449        self.resource.pubsub_items = items
     1450        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    14491451        d = self.handleRequest(xml)
    14501452        d.addCallback(cb)
    14511453        return d
     
    14761478            self.assertEqual(['item1', 'item2'], request.itemIdentifiers)
    14771479            return defer.succeed(None)
    14781480
    1479         self.service.retract = retract
     1481        self.resource.pubsub_retract = retract
     1482        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    14801483        return self.handleRequest(xml)
    14811484
    14821485
     
    15011504            self.assertEqual('test', request.nodeIdentifier)
    15021505            return defer.succeed(None)
    15031506
    1504         self.service.purge = purge
     1507        self.resource.pubsub_purge = purge
     1508        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    15051509        return self.handleRequest(xml)
    15061510
    15071511
     
    15261530            self.assertEqual('test', request.nodeIdentifier)
    15271531            return defer.succeed(None)
    15281532
    1529         self.service.delete = delete
     1533        self.resource.pubsub_delete = delete
     1534        verify.verifyObject(iwokkel.IPubSubResource, self.resource)
    15301535        return self.handleRequest(xml)
    15311536
    15321537
     
    16871692
    16881693    def test_publish(self):
    16891694        """
    1690         Non-overridden L{PubSubService.publish} yields unsupported error.
     1695        Non-overridden L{PubSubResource.publish} yields unsupported error.
    16911696        """
    16921697
    16931698        xml = """
Note: See TracBrowser for help on using the repository browser.