Graham Dumpleton
grahamd at dscpl.com.au
Sat Dec 30 21:19:53 EST 2006
Read description of import_module() in: http://www.modpython.org/live/mod_python-3.3.0b/doc-html/pyapi- apmeth.html How 3.3.0b treats Python packages is a bit different. Your error and configuration suggests that what you had previously was: ./fixuphandler/ # directory __init__.py # package init file. fixuphandler.py # handler file in directory fixuphandler() # handler function in file A little messy, but the important thing is that it only worked before because you had fixuphandler directory organised as a Python package with an __init__.py file and mod_python had automatically add the parent handler directory into sys.path. In 3.3.0b, it doesn't add the parent handler directory into sys.path as that causes various problems. The new importer instead works out where to import things from in a different way. On consequence of this though is that stuff organised as Python packages in a parent handler directory will not be found. You have a few options. 1. Move 'fixuphandler' directory outside of document root and using PythonPath to say where the parent directory of that directory now is. 2. If 'fixuphandler/__init__.py' is empty, then delete that file and change configuration to: PythonFixupHandler fixuphandler/fixuphandler 3. Remove 'fixuphandler/__init__.py' again, but use explicit reference to handler file: PythonFixupHandler ~/fixuphandler/fixuphandler.py If you had stuff in 'fixuphandler/__init__.py' and you expect it to be executed, then you can only do 1 as is. You might want to reconsider restructuring your files though anyway. BTW, if you do not have a 'fixuphandler/.htaccess' which has: deny from all then easy for a user to access stuff in 'fixuphandler' directory that they shouldn't. Ie. they could use URL of: fixuphandler/fixuphandler.py/fixuphandler and mod_python.publisher will call the fixuphandler a second time. If it was doing session stuff, that would cause a deadlock. If the only thing in 'fixuphandler' directory is 'fixuphandler.py', you would perhaps be better off moving 'fixuphandler.py' to the parent directory and call it '_handlers.py'. Because it now has a leading underscore, mod_python.publisher should ignore it and not allow it to be accessed. The configuration would then be: PythonFixupHandler _handlers or: PythonFixupHandler ~/_handlers.py Anyway, read through the documentation I reference, noting that import_module() is what is used to load modules for the Python*Handler directives. Graham On 31/12/2006, at 5:29 AM, m.banaouas wrote: > hi, > I encouter a problem with mod_python-3.3.0b after installed it with > mod_python-3.3.0b.win32-py2.4-Apache2.2.exe. > > my fixuphandler in not founded anymore, although it's always there > (D:/mydir/fixuphandler.py). > after installing again mod_python-3.2.10, every thing works fine > again. > Here in the browser output (PythonDebug On): > > MOD_PYTHON ERROR > > ProcessId: 3520 > Interpreter: 'MACHIN.domaine.local' > > ServerName: 'MACHIN.domaine.local' > DocumentRoot: 'C:/Apache/htdocs' > > URI: '/mydir/api' > Location: None > Directory: 'D:/mydir/' > Filename: 'D:/mydir/api' > PathInfo: '' > > Phase: 'PythonFixupHandler' > Handler: 'fixuphandler.fixuphandler' > > Traceback (most recent call last): > > File "C:\Python\Lib\site-packages\mod_python\importer.py", line > 1537, in HandlerDispatch > default=default_handler, arg=req, silent=hlist.silent) > > File "C:\Python\Lib\site-packages\mod_python\importer.py", line > 1202, in _process_target > module = import_module(module_name, path=path) > > File "C:\Python\Lib\site-packages\mod_python\importer.py", line > 304, in import_module > return __import__(module_name, {}, {}, ['*']) > > ImportError: No module named fixuphandler.fixuphandler > > and here is my httpd.conf contribution: > --- > Alias /mydir "D:/mydir" > > <Directory D:/mydir> > Allow from All > SetHandler mod_python > PythonFixupHandler fixuphandler.fixuphandler > PythonHandler mod_python.publisher > PythonDebug On > </Directory> > --- > > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|