Ignore:
Timestamp:
Mar 7, 2011, 7:40:16 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Make sure item and subscription elements get the correct namespace.

This complements the changes in [f4aa0d507bc8] and [3fe44cf07366] for item and
subscription elements that are used in different namespaces. These changesets
set the namespace to None, which works nicely when the elements are
serialized. However, in situations where the DOM representation is passed
around (in-process communication) these elements are no longer matched by
namespace. This change makes sure the elements get the proper namespace just
before they are sent out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r96 r97  
    139139
    140140
    141     def toElement(self):
     141    def toElement(self, defaultUri=None):
    142142        """
    143143        Return the DOM representation of this subscription.
     
    145145        @rtype: L{domish.Element}
    146146        """
    147         element = domish.Element((None, 'subscription'))
     147        element = domish.Element((defaultUri, 'subscription'))
    148148        if self.nodeIdentifier:
    149149            element['node'] = self.nodeIdentifier
     
    359359        if self.items:
    360360            for item in self.items:
     361                item.uri = NS_PUBSUB
    361362                verbElement.addChild(item)
    362363
     
    12141215    def _toResponse_subscribe(self, result, resource, request):
    12151216        response = domish.Element((NS_PUBSUB, "pubsub"))
    1216         response.addChild(result.toElement())
     1217        response.addChild(result.toElement(NS_PUBSUB))
    12171218        return response
    12181219
     
    12221223        subscriptions = response.addElement('subscriptions')
    12231224        for subscription in result:
    1224             subscriptions.addChild(subscription.toElement())
     1225            subscriptions.addChild(subscription.toElement(NS_PUBSUB))
    12251226        return response
    12261227
     
    13081309
    13091310        for item in result:
     1311            item.uri = NS_PUBSUB
    13101312            items.addChild(item)
    13111313
     
    13581360                                               nodeIdentifier, subscriber,
    13591361                                               subscriptions)
    1360             message.event.items.children = items
     1362            for item in items:
     1363                item.uri = NS_PUBSUB_EVENT
     1364                message.event.items.addChild(item)
    13611365            self.send(message)
    13621366
Note: See TracChangeset for help on using the changeset viewer.