Graham Dumpleton
graham.dumpleton at gmail.com
Thu Sep 13 18:09:26 EDT 2007
Is LcConfig actually a Python package rather than a single Python code file module? >From mod_python 3.3.1, you cannot put Python packages in the document tree due to the separation between document tree module imports and normal sys.path imports. Read documentation for import_module() in: http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html This is the function that underlays imports of modules residing in document tree and is used for top level handlers and mod_python.publisher handlers files. If your code is a Python package, move it outside of the document tree and then use PythonPath directory to refer to the parent directory containing your packages/modules. In general it is not a good idea to be putting common Python packages/modules in the document tree if they aren't actually mod_python handlers. Some, and possibly with good reason, would also recommend that handler code files in document tree be a very thin shell which always simply imports code from outside of the document tree and calls it. The reason for this is so that an Apache misconfiguration doesn't expose your source code. Graham On 14/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote: > (Let me repost a more cogent answer...) > > On 9/12/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote: > > Was mod_python one of the things you upgraded? > > Yep > > > What is the mod_python configuration for that Directory context? > > # LCFIT directory > <Directory /var/www/localhost/htdocs/larry> > SetHandler mod_python > PythonHandler mod_python.publisher > PythonDebug On > #PythonOptimize On > </Directory> > > > On 13/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote: > > > 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/ > > > _______________________________________________ > > > Mod_python mailing list > > > Mod_python at modpython.org > > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > > > >
|