Changeset 909
- Timestamp:
- 01/02/06 15:12:13
- Files:
-
- trunk/cherrypy/lib/cptools.py (modified) (1 diff)
- trunk/cherrypy/test/test_static_filter.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/cptools.py
r896 r909 76 76 response = cherrypy.response 77 77 78 # If path is relative, make absolute using cherrypy.root's module. 79 # If there is no cherrypy.root, or it doesn't have a __module__ 80 # attribute, then users should fix the issue by making path absolute. 81 # That is, CherryPy should not guess where the application root is 82 # any further than trying cherrypy.root.__module__, and it certainly 83 # should *not* use cwd (since CP may be invoked from a variety of 84 # paths). If using static_filter, you can make your relative paths 85 # become absolute by supplying a value for "static_filter.root". 78 # If path is relative, users should fix it by making path absolute. 79 # That is, CherryPy should not guess where the application root is. 80 # It certainly should *not* use cwd (since CP may be invoked from a 81 # variety of paths). If using static_filter, you can make your relative 82 # paths become absolute by supplying a value for "static_filter.root". 86 83 if not os.path.isabs(path): 87 root = os.path.dirname(sys.modules[cherrypy.root.__module__].__file__) 88 path = os.path.join(root, path) 84 raise ValueError("'%s' is not an absolute path." % path) 89 85 90 86 try: trunk/cherrypy/test/test_static_filter.py
r900 r909 35 35 'static_filter.on': True, 36 36 'static_filter.dir': 'static', 37 'static_filter.root': curdir, 37 38 }, 38 39 '/style.css': { 39 40 'static_filter.on': True, 40 41 'static_filter.file': 'style.css', 42 'static_filter.root': curdir, 41 43 }, 42 44 '/docroot': { … … 57 59 58 60 def testStaticFilter(self): 59 # This should resolve relative to cherrypy.root.__module__.60 61 self.getPage("/static/index.html") 61 62 self.assertStatus('200 OK') … … 63 64 self.assertBody('Hello, world\r\n') 64 65 65 # Using a static_filter.root value ...66 # Using a static_filter.root value in a subdir... 66 67 self.getPage("/docroot/index.html") 67 68 self.assertStatus('200 OK')

