Graham Dumpleton
grahamd at dscpl.com.au
Sun Jul 17 04:56:06 EDT 2005
Is it all perhaps because you have: SetHandler mod_python PythonHandler mod_python.publisher rather than: AddHandler mod_python .py PythonHandler mod_python.publisher I had noted you were using SetHandler but presumed you were doing it for a good reason and that only Python stuff was in the "python" subdirectory. If you have other file types in the "python" subdirectory and expect Apache to serve them up normally, you cant use "SetHandler". You would need to use "AddHandler" and only have requests with a ".py" extension served by mod_python.publisher. Graham On 17/07/2005, at 6:47 PM, Wouter van Marle wrote: > As test, I've removed all the python content of the site. I've a file > index.html that just displays "hello world!". And I still have the same > error! Now it's getting really weird. The index.shtml file as supplied > by the apache installation gives the same error. URL used was > http://localhost/index.html and http://localhost/index.shtml. > > Then the try/except thing as you suggested, this basically the same > result as the error message on the screen. > > However, I just found that when typing > http://localhost/python/main.py/home directly in the address bar, the > site is displayed. Without the images, and without the css based > layout, > files which for some reason are tried imported as python modules. I get > error messages in error.log such as: > [notice] mod_python: (Re)importing module 'main.css' with path set to > '['/var/www/html']' > followed a bit later by: > [client 127.0.0.1] PythonHandler mod_python.publisher: ImportError: No > module named css, referer: http://localhost/python/main.py/home > > Similar results with the .png images! > The referer is indeed the script/function that calls the psp.run() > function to display the page. It seems my apache tries to import every > single file as if it is a python module, unless it is passed directly > to > apache through the req.write() method. > > So time to start looking very hard again at my apache configuration... > > Wouter. > > On Sun, 2005-07-17 at 10:35 +1000, Graham Dumpleton wrote: >> You might then be getting hit by this problem then: >> >> http://issues.apache.org/jira/browse/MODPYTHON-24 >> >> Your main.py might have an import error of some form and as a result >> the publisher is instead trying to load index.py to find a function >> in it called main(). The bug means you see any error in not being >> able to find index.py rather than why main.py perhaps failed to load >> in the first place. >> >> Suggest that in main.py you do something like the following: >> >> import sys, traceback >> from mod_python import apache >> >> try: >> # all your existing code in the module indented >> >> except: >> >> apache.log_error("exception=%r"%traceback.format_tb(sys.exc_info()[2]) >> ) >> raise >> >> If the problem is that main.py is experiencing an import error, you >> would now be able to see it. >> >> Alternatively, you might be able to rename main.py to index.py and >> access it through appropriate URL. Because it is the index.py file, >> it might not try and fall through to the index file and you might see >> any import error then. >> >> Graham >> >> On 17/07/2005, at 2:06 AM, Wouter van Marle wrote: >> >>> Graham, >>> >>> Thanks for the quick replies. >>> Your suggestion with a complete path indeed didn't change anything. >>> Where/what is that module 'index' by the way? I can not find it. >>> >>> Directory structure: >>> /var/www/html is the server root >>> /var/www/html/python contains all the python files >>> accessing the file: >>> http://localhost/ >>> which should call index.html, which contains a redirect >>> to /python/main.py/index >>> >>> Regarding MultiViews: that seems to be enabled (I don't know what it >>> is, >>> I just leave it to the default installation values). In >>> commonhttpd.conf >>> I have the following: >>> >>> <Directory /> >>> Options -All -Multiviews >>> >>> <Directory /var/www/html> >>> Options -Indexes FollowSymLinks MultiViews >>> >>> Wouter. >>> >>> On Sat, 2005-07-16 at 22:27 +1000, Graham Dumpleton wrote: >>>> Presuming that the location '/python' maps to a physical directory >>>> called '/var/www/html/python', try instead using: >>>> >>>> <Directory /var/www/html/python> >>>> SetHandler python-program >>>> PythonHandler mod_python.publisher >>>> </Directory> >>>> >>>> When <Location> is used, there is no associated physical directory >>>> and therefore mod_python can't know what directory to add to the >>>> PythonPath (sys.path) for you. >>>> >>>> Only problem with this theory as I just realised though is that >>>> mod_python.publisher shouldn't be relying on sys.path to load the >>>> actual modules. It will instead explicitly provide the directory >>>> to apache.import_module(). In other words, it should work okay >>>> how you had it. >>>> >>>> What was the URL you were using to access the page? Do you know >>>> if "MultiViews" Apache option is enabled or disabled for that >>>> directory? >>>> >>>> Graham >>>> >>>> On 16/07/2005, at 10:09 PM, Wouter van Marle wrote: >>>> >>>>> Graham, >>>>> >>>>> Here the relevant details: >>>>> >>>>> in httpd2.conf one line: >>>>> >>>>> LoadModule python_module extramodules/mod_python.so >>>>> >>>>> >>>>> In 16_mod_python.conf: >>>>> >>>>> <Location /python> >>>>> SetHandler python-program >>>>> PythonHandler mod_python.publisher >>>>> </Location> >>>>> >>>>> After dinner I'm going to look into this more! This is the current >>>>> setup. >>>>> >>>>> Wouter. >>>>> >>>>> On Sat, 2005-07-16 at 21:41 +1000, Graham Dumpleton wrote: >>>>>> Have you specified: >>>>>> >>>>>> PythonHandler mod_python.publisher >>>>>> >>>>>> within a <Directory> directive or in a .htaccess file? >>>>>> >>>>>> If you haven't and you instead put it at global scope or within a >>>>>> <Location> directive, you can have such problems because >>>>>> PythonPath >>>>>> will not be automatically extended with the name of the directory >>>>>> for which PythonHandler is specified. >>>>>> >>>>>> Alternatively, are you setting PythonPath explicitly in any way? >>>>>> Setting PythonPath explicitly can also override the automatic >>>>>> addition >>>>>> of the PythonHandler directive to PythonPath and again module will >>>>>> not be able to be found. >>>>>> >>>>>> You might want to post the snippet of Apache configuration where >>>>>> you >>>>>> setup use of mod_python. There is no need to send the whole Apache >>>>>> configuration, just the relevant bit, ensuring though you show any >>>>>> context it is set within, such as <Location>, <Directory> when it >>>>>> is appropriate. >>>>>> >>>>>> Graham >>>>>> >>>>>> On 16/07/2005, at 9:27 PM, Wouter van Marle wrote: >>>>>> >>>>>>> Hi all, >>>>>>> >>>>>>> After an upgrade to Mandrake 10.2, mod_python shows the >>>>>>> following >>>>>>> error: >>>>>>> >>>>>>> Mod_python error: "PythonHandler mod_python.publisher" >>>>>>> >>>>>>> Traceback (most recent call last): >>>>>>> >>>>>>> File "/usr/lib/python2.4/site-packages/mod_python/apache.py", >>>>>>> line >>>>>>> 299, in HandlerDispatch >>>>>>> result = object(req) >>>>>>> >>>>>>> File >>>>>>> "/usr/lib/python2.4/site-packages/mod_python/publisher.py", >>>>>>> line 98, in handler >>>>>>> path=[path]) >>>>>>> >>>>>>> File "/usr/lib/python2.4/site-packages/mod_python/apache.py", >>>>>>> line >>>>>>> 454, in import_module >>>>>>> f, p, d = imp.find_module(parts[i], path) >>>>>>> >>>>>>> ImportError: No module named index >>>>>>> >>>>>>> >>>>>>>> From my address bar I can see that this is before the very first >>>>>>> page (an html page that redirects to the python based content and >>>>>>> thereby changes the url in the address bar). Any idea what's >>>>>>> going >>>>>>> wrong here? >>>>>>> >>>>>>> The software, from rpm packages: >>>>>>> apache2-2.0.53-9mdk >>>>>>> apache2-mod_python-2.0.53_3.1.4-4mdk >>>>>>> python-base-2.4.1-2mdk >>>>>>> python-2.4.1-2mdk >>>>>>> >>>>>>> Wouter. _______________________________________________ >>>>>>> Mod_python mailing list >>>>>>> Mod_python at modpython.org >>>>>>> http://mailman.modpython.org/mailman/listinfo/mod_python >>>>>> >>>>>> >>>> >>>> >>> >>> _______________________________________________ >>> Mod_python mailing list >>> Mod_python at modpython.org >>> http://mailman.modpython.org/mailman/listinfo/mod_python >> >>
|