Changeset 47:f6d222b68f1c in ralphm-patches


Ignore:
Timestamp:
Mar 7, 2011, 7:39:36 PM (9 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Many new patches, upstreamed affiliations and worked on pubsub item.
Upstreamed pubsub_manage_affiliations

Files:
11 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • pubsub-item.patch

    r45 r47  
    1 diff -r e58b9f2cf8a3 wokkel/pubsub.py
    2 --- a/wokkel/pubsub.py  Fri Jan 01 01:34:14 2010 +0100
    3 +++ b/wokkel/pubsub.py  Fri Jan 01 11:12:36 2010 +0100
    4 @@ -119,33 +119,47 @@
     1diff -r d16bd03316ad wokkel/generic.py
     2--- a/wokkel/generic.py Mon Feb 28 09:31:41 2011 +0100
     3+++ b/wokkel/generic.py Mon Feb 28 09:43:34 2011 +0100
     4@@ -38,13 +38,12 @@
     5     @return: The DOM structure, or C{None} on empty or incomplete input.
     6     @rtype: L{domish.Element}
     7     """
     8-    roots = []
     9     results = []
     10     elementStream = domish.elementStream()
     11-    elementStream.DocumentStartEvent = roots.append
     12-    elementStream.ElementEvent = lambda elem: roots[0].addChild(elem)
     13-    elementStream.DocumentEndEvent = lambda: results.append(roots[0])
     14-    elementStream.parse(string)
     15+    elementStream.DocumentStartEvent = lambda _: None
     16+    elementStream.ElementEvent = lambda elem: results.append(elem)
     17+    elementStream.DocumentEndEvent = lambda: None
     18+    elementStream.parse('<dummy>%s</dummy>' % string)
     19     return results and results[0] or None
     20 
     21 
     22diff -r d16bd03316ad wokkel/pubsub.py
     23--- a/wokkel/pubsub.py  Mon Feb 28 09:31:41 2011 +0100
     24+++ b/wokkel/pubsub.py  Mon Feb 28 09:43:34 2011 +0100
     25@@ -157,33 +157,56 @@
    526 
    627 
     
    1536-    Item payload can be added using C{addChild} or C{addRawXml}, or using the
    1637-    C{payload} keyword argument to C{__init__}.
    17 +    @ivar itemIdentifier: optional item identifier
     38+    @ivar itemIdentifier: Optional item identifier.
    1839+    @type itemIdentifier: L{unicode}
    19 +    @ivar payload: optional item payload. Either as a domish element, or as
     40+    @ivar payload: Optional item payload. Either as a L{domish.Element}, or as
    2041+        serialized XML.
    21 +    @type payload: object providing L{domish.IElement} or L{unicode}.
     42+    @type payload: Object providing L{domish.IElement} or L{unicode}.
     43+    @ivar timestamp: Optional timestamp when the item was published as 8601
     44+    string. Timestamps that include a time component must have a time zone
     45+    indicated.
     46+    @type timestamp: C{unicode}
     47+    @ivar publisher: Optional entity that published this item.
     48+    @type publisher: L{JID}
    2249     """
    2350 
    2451-    def __init__(self, id=None, payload=None):
    25 +    def __init__(self, itemIdentifier=None, payload=None):
     52+    def __init__(self, itemIdentifier=None, payload=None,
     53+                       timestamp=None, publisher=None):
    2654+        self.itemIdentifier = itemIdentifier
    2755+        self.payload = payload
     56+        self.timestamp = timestamp
     57+        self.publisher = publisher
    2858+
    2959+
     
    5989+        if self.payload is not None:
    6090+            if isinstance(self.payload, basestring):
    61 +                self.addRawXml(self.payload)
     91+                element.addRawXml(self.payload)
    6292             else:
    6393-                self.addChild(payload)
    64 +                self.addChild(self.payload)
     94+                element.addChild(self.payload)
    6595+
    6696+        return element
     
    6898 
    6999 
    70 @@ -309,7 +323,13 @@
     100@@ -351,7 +374,13 @@
    71101         self.items = []
    72102         for element in verbElement.elements():
     
    83113 
    84114     def _render_items(self, verbElement):
    85 @@ -318,7 +338,7 @@
     115@@ -360,8 +389,7 @@
    86116         """
    87117         if self.items:
    88118             for item in self.items:
     119-                item.uri = NS_PUBSUB
    89120-                verbElement.addChild(item)
    90121+                verbElement.addChild(item.toElement())
     
    92123 
    93124     def _parse_jid(self, verbElement):
    94 @@ -1124,7 +1144,7 @@
     125@@ -1307,8 +1335,7 @@
    95126         items["node"] = request.nodeIdentifier
    96127 
    97128         for item in result:
     129-            item.uri = NS_PUBSUB
    98130-            items.addChild(item)
    99131+            items.addChild(item.toElement())
     
    101133         return response
    102134 
    103 diff -r e58b9f2cf8a3 wokkel/test/test_pubsub.py
    104 --- a/wokkel/test/test_pubsub.py        Fri Jan 01 01:34:14 2010 +0100
    105 +++ b/wokkel/test/test_pubsub.py        Fri Jan 01 11:12:36 2010 +0100
    106 @@ -365,7 +365,6 @@
     135@@ -1359,8 +1386,7 @@
     136                                                nodeIdentifier, subscriber,
     137                                                subscriptions)
     138             for item in items:
     139-                item.uri = NS_PUBSUB_EVENT
     140-                message.event.items.addChild(item)
     141+                message.event.items.addChild(item.toElement(NS_PUBSUB_EVENT))
     142             self.send(message)
     143 
     144 
     145diff -r d16bd03316ad wokkel/test/test_pubsub.py
     146--- a/wokkel/test/test_pubsub.py        Mon Feb 28 09:31:41 2011 +0100
     147+++ b/wokkel/test/test_pubsub.py        Mon Feb 28 09:43:34 2011 +0100
     148@@ -115,6 +115,30 @@
     149 
     150 
     151 
     152+class ItemTest(unittest.TestCase):
     153+
     154+    def test_toElement(self):
     155+        item = pubsub.Item(itemIdentifier='test')
     156+        element = item.toElement()
     157+        self.assertEquals('test', element.getAttribute('id'))
     158+
     159+
     160+    def test_toElementPayload(self):
     161+        payload = domish.Element(('testns', 'test'))
     162+        item = pubsub.Item(itemIdentifier='test', payload=payload)
     163+        element = item.toElement()
     164+        self.assertNotIdentical(None, element.test)
     165+        self.assertEquals('testns', element.test.uri)
     166+
     167+
     168+    def test_toElementPayloadRawXML(self):
     169+        payload = u"<test xmlns='testns'/>"
     170+        item = pubsub.Item(itemIdentifier='test', payload=payload)
     171+        element = item.toElement()
     172+        self.assertEquals(1, len(element.children))
     173+        self.assertEquals(payload, element.children[0])
     174+
     175+
     176 class PubSubClientTest(unittest.TestCase):
     177     timeout = 2
     178 
     179@@ -465,7 +489,6 @@
    107180         items = list(domish.generateElementsQNamed(child.children,
    108181                                                    'item', NS_PUBSUB))
     
    112185         response = toResponse(iq, 'result')
    113186         self.stub.send(response)
    114 @@ -699,8 +698,8 @@
     187@@ -1048,8 +1071,8 @@
    115188 
    116189         request = pubsub.PubSubRequest.fromElement(parseXml(xml))
     
    122195 
    123196 
     197     def test_fromElementPublishItemsOptions(self):
     198@@ -1075,8 +1098,9 @@
     199 
     200         request = pubsub.PubSubRequest.fromElement(parseXml(xml))
     201         self.assertEqual(2, len(request.items))
     202-        self.assertEqual(u'item1', request.items[0]["id"])
     203-        self.assertEqual(u'item2', request.items[1]["id"])
     204+        self.assertEqual(u'item1', request.items[0].itemIdentifier)
     205+        self.assertEqual(u'item2', request.items[1].itemIdentifier)
     206+
     207 
    124208     def test_fromElementPublishNoNode(self):
     209         """
  • series

    r45 r47  
    1 pubsub_manage_affiliations.patch
    2 pubsub-item.patch #+deferred
    3 blah.patch
    4 disco_simplify_gatherResults.patch #+deferred
     1copyright.patch
     2pubsub-correct-namespace.patch
     3connectionLost-reason.patch
     4addHandler-48.patch
     5request-tracking.patch
     6request-xmpphandler.patch
     7request-stanza.patch
     8disco-addressing.patch
     9disco_warning.patch #-compatible
     10pubsub-default-type-attribute.patch #+deferred
     11pubsub-item.patch #-compatible
    512roster_item.patch
    613roster_server.patch
    714xmpp_client_service.patch
     15disco_simplify_gatherResults.patch #+deferred
     16deprecate_xmpphandler.patch #+deferred
    817s2s-controller.patch #+deferred
Note: See TracChangeset for help on using the changeset viewer.