[Twisted-web] Nevow patches

Tristan Seligmann mithrandi-twisted-web at mithrandi.za.net
Tue Jul 12 03:59:40 MDT 2005


Hi,

Just two quick Nevow patches. The first changes livepage.js.__getitem__
to accept a list or a tuple, and handle an empty sequence. The second
should fix handling of URLs containing quoted slashes.
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar
-------------- next part --------------
Index: nevow/test/test_livepage.py
===================================================================
--- nevow/test/test_livepage.py	(revision 1620)
+++ nevow/test/test_livepage.py	(working copy)
@@ -172,6 +172,10 @@
         self.assertEquals(self.livepage.sent, "array[5]")
         self.livepage.sendScript(livepage.js[1,2,3])
         self.assertEquals(self.livepage.sent, "[1,2,3]")
+        self.livepage.sendScript(livepage.js[()])
+        self.assertEquals(self.livepage.sent, "[]")
+        self.livepage.sendScript(livepage.js[[1,2,3]])
+        self.assertEquals(self.livepage.sent, "[1,2,3]")
 
     def test_setAndAppend(self):
         for apiName in ['set', 'append']:
Index: nevow/livepage.py
===================================================================
--- nevow/livepage.py	(revision 1620)
+++ nevow/livepage.py	(working copy)
@@ -176,11 +176,12 @@
         return self.__class__(newchildren)
 
     def __getitem__(self, args):
-        if not isinstance(args, tuple):
+        if not isinstance(args, (tuple, list)):
             args = (args,)
         newchildren = self._children[:]
         stuff = [(x, stan.raw(',')) for x in args]
-        stuff[-1] = stuff[-1][0]
+        if stuff:
+            stuff[-1] = stuff[-1][0]
         newchildren.extend([stan.raw("["), stuff, stan.raw("]")])
         return self.__class__(newchildren)
 
-------------- next part --------------
Index: nevow/url.py
===================================================================
--- nevow/url.py	(revision 1442)
+++ nevow/url.py	(working copy)
@@ -68,7 +68,7 @@
         scheme, netloc, path, query, fragment = urlparse.urlsplit(st)
         u = klass(
             scheme, netloc,
-            [raw(urllib.unquote(seg)) for seg in path.split('/')[1:]],
+            [urllib.unquote(seg) for seg in path.split('/')[1:]],
             unquerify(query), fragment)
         return u
     fromString = classmethod(fromString)


More information about the Twisted-web mailing list