grahamd at dscpl.com.au
Tue May 9 00:16:51 EDT 2006
Mohamed Sordo wrote .. > Hi everybody, > I've some problems with my mod_python. > I'm trying to execute server_side.py via mod_python. > I have a mod_python_my_files.conf in /etc/apache2/conf.d/ > > It seems like that: > > <IfModule mod_alias.c> > Alias /my_server /home/neomoha/PFC/src/server_side.py > </IfModule> > <DirectoryMatch /home/neomoha/PFC/src/ > I would recommend not using DirectoryMatch as mod_python can't handle a regular expression or globex style path using this directive or the Directory directive. Such support may make it into mod_python 3.3. Use a straight path instead for now: <Directory /home/neomoha/PFC/src/> Overall, unless you have a PythonPath set at global scope which is causing directory associated with directive to not be added to sys.path automatically, not sure why it wouldn't find it. Other possibility is how you are using Alias is screwing things up. Can you add to the start of your module: from mod_python import apache import sys apache.log_error('__file__=%s' % __file__) apache.log_error('path=%s' % sys.path) to see what sys.path is set to when import is occurring and post the result here if you haven't yet worked it out. The messages will be logged in the Apache error log file. > # mod_python 3.X > AddHandler mod_python .py > PythonHandler mod_python.publisher > PythonDebug On > > Options +FollowSymLinks > > Order allow,deny > Allow from all > </DirectoryMatch> > > NOTE: server-side.py is rwx for everybody > > When a execute a python script that uses my localhost connection with > mod_python , I have this output: > > Traceback (most recent call last): > > File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, > in > HandlerDispatch > result = object(req) > > File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line > 98, > in handler > path=[path]) > > File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 457, > in > import_module > module = imp.load_module(mname, f, p, d) > > File "/home/neomoha/PFC/src/server_side.py", line 22, in ? > from myfile import MyFile > > ImportError: cannot import name MyFile > > NOTE: myfile.py is in /home/neomoha/PFC/src/ directory. > And I'm using Apache/2.0.55 (Debian) mod_python/3.1.3 Python/2.3.5 Server > at > localhost Port 80 > > Thanks for any answer, > Mohamed.