Anonymous avatar Anonymous committed 73c23d4

Fixed unittest and static directory handling

Comments (0)

Files changed (2)

cherrypy/_cphttptools.py

     cpg.request.originalParamTuple = cpg.request.paramTuple
 
     path = cpg.request.path
+    if path.startswith('/'): path = path[1:] # Remove leading slash
+    if path.endswith('/'): path = path[:-1] # Remove trailing slash
 
     # Handle static directories
     for urlDir, fsDir in cpg.configOption.staticContentList:
     previousObj = getObjFromPath(objPathList[:-1], objCache)
     obj = getattr(previousObj, objPathList[-1], None)
     objCache[cacheKey] = obj
+    # print "*** GETTING:", objPathList, repr(obj)
     return obj
 
 def mapPathToObject():

cherrypy/unittest/unittest.py

     ('01', ['/'], ['Hello world!']),
     ('02', ['/showMessage'], ['Hello world!']),
     ('03', ['/greetUser?name=Bob'], ["Hey Bob, what's up?"]),
-    ('04', ['/links/extra'], ['\n            <p>Here are some extra useful links:</p>\n\n            <ul>\n                <li><a href="http://del.icio.us">del.icio.us</a></li>\n                <li><a href="http://www.mornography.de">Hendrik\'s weblog</a></li>\n            </ul>\n\n            <p>[<a href="../">Return to links page</a>]</p>\n        ']),
-    ('05', ['/another'], ['\n            <html>\n            <head>\n                <title>Another Page</title>\n            <head>\n            <body>\n            <h2>Another Page</h2>\n        \n            <p>\n            And this is the amazing second page!\n            </p>\n        \n            </body>\n            </html>\n        ']),
+    ('04', ['/links/extra/'], ['\n            <p>Here are some extra useful links:</p>\n\n            <ul>\n                <li><a href="http://del.icio.us">del.icio.us</a></li>\n                <li><a href="http://www.mornography.de">Hendrik\'s weblog</a></li>\n            </ul>\n\n            <p>[<a href="../">Return to links page</a>]</p>\n        ']),
+    ('05', ['/another/'], ['\n            <html>\n            <head>\n                <title>Another Page</title>\n            <head>\n            <body>\n            <h2>Another Page</h2>\n        \n            <p>\n            And this is the amazing second page!\n            </p>\n        \n            </body>\n            </html>\n        ']),
     ('06', ['/'], ['\n            <html>\n            <head>\n                <title>Tutorial 6 -- Aspect Powered!</title>\n            <head>\n            <body>\n            <h2>Tutorial 6 -- Aspect Powered!</h2>\n        \n            <p>\n            Isn\'t this exciting? There\'s\n            <a href="./another/">another page</a>, too!\n            </p>\n        \n            </body>\n            </html>\n        ']), 
     ('07', ['/hendrik'], ['Hendrik Mans, CherryPy co-developer & crazy German (<a href="./">back</a>)']), 
     ('08', ['/', '/'], ["\n            During your current session, you've viewed this\n            page 1 times! Your life is a patio of fun!\n        ", "\n            During your current session, you've viewed this\n            page 2 times! Your life is a patio of fun!\n        "]), 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.