Graham Dumpleton
graham.dumpleton at gmail.com
Sun Feb 7 17:05:39 EST 2010
You can't use a relative path as the current working directory when running under Apache can be anything. So, use an absolute path, or find a way with the framework you are using to make it resolve the relative path relative to the actual directory the template is in. Graham On 8 February 2010 00:01, Julien Pecqueur <jpec at julienpecqueur.com> wrote: > Hi, > > I got an error when trying to access to files which are located in a sub-directory. > >> File "/var/www/dev/pygitweb/PyGitWeb.py", line 88, in read_template >> template = open(self.template_path, 'r') >> >> IOError: [Errno 2] No such file or directory: 'templates/template.xhtml' > > > The template.xhtml file exist in the sub-directory templates : > >> Index of /dev/pygitweb/templates >> >> Name Last modified Size Description >> Parent Directory - >> style.css 06-Feb-2010 21:20 0 >> template.xhtml 06-Feb-2010 21:20 588 > > When i execute the python scrit via the shell, it just works fine. I try with lighttpd + cgi + python and it works too. > > I tryed to replace the file path by full path /var/http/dev/pygitweb/templates/template.xhtml but i got ht same error. > > Any ideas ? > > > > > > Here the full error message : > > MOD_PYTHON ERROR > > ProcessId: 3185 > Interpreter: 'server.julienpecqueur.com' > > ServerName: 'server.julienpecqueur.com' > DocumentRoot: '/var/www/' > > URI: '/dev/pygitweb/PyGitWeb.py' > Location: None > Directory: '/var/www/dev/pygitweb/' > Filename: '/var/www/dev/pygitweb/PyGitWeb.py' > PathInfo: '' > > Phase: 'PythonHandler' > Handler: 'mod_python.publisher' > > Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch > default=default_handler, arg=req, silent=hlist.silent) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target > result = _execute_target(config, req, object, arg) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target > result = object(arg) > > File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line 204, in handler > module = page_cache[req] > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1059, in __getitem__ > return import_module(req.filename) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 296, in import_module > log, import_path) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 680, in import_module > execfile(file, module.__dict__) > > File "/var/www/dev/pygitweb/PyGitWeb.py", line 153, in <module> > Result = Page.build() > > File "/var/www/dev/pygitweb/PyGitWeb.py", line 95, in build > self.read_template() > > File "/var/www/dev/pygitweb/PyGitWeb.py", line 88, in read_template > template = open(self.template_path, 'r') > > IOError: [Errno 2] No such file or directory: 'templates/template.xhtml' > > > MODULE CACHE DETAILS > > Accessed: Sun Feb 7 13:40:16 2010 > Generation: 0 > > _mp_a38b6d9b42b21e0116cc275fffcfc04b { > FileName: '/var/www/dev/pygitweb/PyGitWeb.py' > Instance: 1 [IMPORT] > Generation: 0 [ERROR] > Modified: Sun Feb 7 12:36:47 2010 > } > > > > -- > Julien Pecqueur (JPEC) > > Site: http://julienpecqueur.com > Email: jpec at julienpecqueur.com > PGP: B1AA2389 (GNUPG) > IRC: jpec (irc.freenode.net) > > Powered by Archlinux - Keep it simple stupid ! > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > >
|