chenqingyu / auto-sub

Automatically exported from code.google.com/p/auto-sub
0 stars 0 forks source link

Relative template paths broken when #201

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On my NAS server, the application resides in another directory than the 
configuration/caches/db. This causes problems due to current working directory 
and file resolving:

HTTP Traceback (most recent call last):
  File "/mnt/apps/auto-sub/cherrypy/_cprequest.py", line 656, in respond
    response.body = self.handler()
  File "/mnt/apps/auto-sub/cherrypy/lib/encoding.py", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/mnt/apps/auto-sub/cherrypy/_cpdispatch.py", line 34, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/mnt/apps/auto-sub/autosub/WebServer.py", line 260, in index
    tmpl = PageTemplate(file="interface/templates/home.tmpl")
  File "/usr/local/lib/python2.7/site-packages/Cheetah-2.4.4-py2.7-linux-armv7l.egg/Cheetah/Template.py", line 1259, in __init__
    self._compile(source, file, compilerSettings=compilerSettings)
  File "/usr/local/lib/python2.7/site-packages/Cheetah-2.4.4-py2.7-linux-armv7l.egg/Cheetah/Template.py", line 1546, in _compile
    self._fileMtime = os.path.getmtime(file)
  File "/usr/local/lib/python2.7/genericpath.py", line 54, in getmtime
    return os.stat(filename).st_mtime
OSError: [Errno 2] No such file or directory: 
'/mnt/apps/userdata/auto-sub/interface/templates/home.tmpl'

As one can see, the file 
'/mnt/apps/userdata/auto-sub/interface/templates/home.tmpl' is requested, but 
this file resides in /mnt/apps/auto-sub/interface/templates/home.tmpl' (note 
the userdata folder).

The current working directory (?) is determined via the path variable in 
config.properties file. However, the interface folder resides in the 
application directory, not of the userdata directory.

I have changed the source to include a variable autosub.BASE_DIR, which is set 
in the main() method. This variables points to the directory where the 
AutoSub.py file resides and is used to resolve templates and other application 
files. The path variable in config.properties is still used to point to the 
userdata directory.

A patch is attached, but I haven't tested it thoroughly. Especially the 
templates are more or less the result of Replace All. The patch is checked out 
against the latest source. 

Original issue reported on code.google.com by basstott...@gmail.com on 25 Jun 2013 at 10:59

Attachments:

GoogleCodeExporter commented 9 years ago
The title should be 'Relative template paths broken'. I cannot find the edit 
button. My bad.

Original comment by basstott...@gmail.com on 25 Jun 2013 at 11:01