]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: link to directory URIs rather than a child path. Addresses #103.
authorBrian Warner <warner@allmydata.com>
Wed, 30 Jan 2008 01:04:32 +0000 (18:04 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 30 Jan 2008 01:04:32 +0000 (18:04 -0700)
src/allmydata/test/test_web.py
src/allmydata/webish.py

index 69d9bb5b606ee14f73bc0eb9fb6e7f627fbaedde..6d241e908550b98360f46f925caf94e24dc83975 100644 (file)
@@ -599,7 +599,8 @@ class Web(WebMixin, unittest.TestCase):
                                       '\s+<td>FILE</td>'
                                       '\s+<td>%d</td>' % len(self.BAR_CONTENTS)
                                       , res))
-            self.failUnless(re.search(r'<td><a href="sub">sub</a></td>'
+            # the DIR reference just points to a URI
+            self.failUnless(re.search(r'<td><a href="/uri/URI%3ADIR2%3A[^"]+">sub</a></td>'
                                       '\s+<td>DIR</td>', res))
         d.addCallback(_check)
 
@@ -615,7 +616,7 @@ class Web(WebMixin, unittest.TestCase):
         d.addCallback(lambda res:
                       self.GET(self.public_url, followRedirect=True))
         def _check3(res):
-            self.failUnless(re.search(r'<td><a href="reedownlee">reedownlee</a>'
+            self.failUnless(re.search(r'<td><a href="/uri/URI%3ADIR2-RO%3A[^"]+">reedownlee</a>'
                                       '</td>\s+<td>DIR-RO</td>', res))
         d.addCallback(_check3)
 
@@ -653,7 +654,8 @@ class Web(WebMixin, unittest.TestCase):
         d.addCallback(_check)
 
         def _done(res):
-            self.failUnless('<a href="%d">%d</a>' % (COUNT-1, COUNT-1) in res)
+            m = r'<a href="/uri/URI%3ADIR2%3A[^"]+">' + ("%d" % (COUNT-1)) + r'</a>'
+            self.failUnless(re.search(m, res))
             self.failIf("maximum recursion depth exceeded" in res)
         d.addCallback(_done)
         return d
index d7e9863006dc52971087a5fc07c8550759caae9c..dda50a56c401f49d363ae7cf4e5bcde7335edcf6 100644 (file)
@@ -256,9 +256,8 @@ class Directory(rend.Page):
 
         elif IDirectoryNode.providedBy(target):
             # directory
-            subdir_url = urllib.quote(name)
             ctx.fillSlots("filename",
-                          T.a(href=subdir_url)[html.escape(name)])
+                          T.a(href=uri_link)[html.escape(name)])
             if target.is_readonly():
                 dirtype = "DIR-RO"
             else:
@@ -1296,7 +1295,7 @@ class Root(rend.Page):
                     return rend.NotFound
                 uri = segments[1]
                 d = defer.maybeDeferred(client.create_node_from_uri, uri)
-                d.addCallback(lambda node: VDrive(node, "from-uri"))
+                d.addCallback(lambda node: VDrive(node, uri))
                 d.addCallback(lambda vd: vd.locateChild(ctx, segments[2:]))
                 def _trap_KeyError(f):
                     f.trap(KeyError)