Commits

Robert Brewer committed eb0095d

Docs and new url() test.

  • Participants
  • Parent commits 6109023

Comments (0)

Files changed (3)

cherrypy/__init__.py

                 atoms.append(atom)
         newurl = '/'.join(atoms)
     
+    # At this point, we should have a fully-qualified absolute URL.
+    
     if relative:
         old = url().split('/')[:-1]
         new = newurl.split('/')

cherrypy/_cprequest.py

     set to 'False' if it failed and to the 'username' value if it succeeded.
     The default 'None' implies that no authentication happened."""
     
+    # Note that cherrypy.url uses "if request.app:" to determine whether
+    # the call is during a real HTTP request or not. So leave this None.
     app = None
     app__doc = \
         """The cherrypy.Application object which is handling this request."""

cherrypy/test/test_core.py

         def upload(self, file):
             return "Size: %s" % len(file.file.read())
         upload.exposed = True
+        
+        def baseurl(self, path_info, relative=None):
+            return cherrypy.url(path_info, relative=bool(relative))
+        baseurl.exposed = True
     
     root = Root()
     
         self.assertBody('../page1')
         self.getPage('/url/?path_info=other/../page1&relative=True')
         self.assertBody('page1')
+        
+        # Output relative to /
+        self.getPage('/baseurl?path_info=ab&relative=True')
+        self.assertBody('ab')
+        # Output relative to /
+        self.getPage('/baseurl?path_info=/ab&relative=True')
+        self.assertBody('ab')
 
 
 if __name__ == '__main__':