[mod_python] Cheetah / mod_python problem: importing python module into cheetah template

Webb Sprague webb.sprague at gmail.com
Wed Sep 12 14:47:36 EDT 2007


Hi all,

Sorry for the redundancy, but I didn't get a response on the Cheetah
mailing list (probably dead because they use SF), so here I go again:

I am using modpython 3.3.1, cheetah 2.0rc8, python2.5, and apache2 on
a gentoo machine.  I recently upgraded a bunch of stuff on the machine
- it had worked six months ago with different apache etc.

The templates are used by calling:

pageTemplate = Template.Template(file=self.navTemplate, searchList =
searchList)

#... and then ...

req.write(str(pageTemplate))

I have a template that has the following code at the top:

#import sys
#import os
#$sys.path.append('/var/www/localhost/htdocs/larry/')  ## path of following
#from LcConfig import *

But I get an error in my apache logs saying the module can't be found
- please help!

Log dump:

[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133] Traceback
(most recent call last):, referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch\n    default=default_handler, arg=req,
silent=hlist.silent), referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target\n    result = _execute_target(config, req,
object, arg), referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target\n    result = object(arg), referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/publisher.py", line
213, in handler\n    published = publish_object(req, object), referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/publisher.py", line
425, in publish_object\n    return
publish_object(req,util.apply_fs_data(object, req.form, req=req)),
referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/mod_python/util.py", line 554, in
apply_fs_data\n    return object(**args), referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/var/www/localhost/htdocs/larry/LcPageObjects.py", line 55, in
__call__\n    formTemplate = Template.Template(file=self.formTemplate,
searchList = searchList), referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/Cheetah/Template.py", line 1204,
in __init__\n    self._compile(source, file,
compilerSettings=compilerSettings), referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/Cheetah/Template.py", line 1492,
in _compile\n    keepRefToGeneratedCode=True), referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"/usr/lib64/python2.5/site-packages/Cheetah/Template.py", line 780, in
compile\n    exec co in mod.__dict__, referer:
http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133]   File
"_var_www_localhost_htdocs_larry_TEMPLATES_LoginForm_tmpl.py", line
25, in <module>, referer: http://lare.demog.berkeley.edu/
[Mon Sep 10 11:20:53 2007] [error] [client 75.170.29.133] ImportError:
No module named LcConfig, referer: http://lare.demog.berkeley.edu/


More information about the Mod_python mailing list