Graham Dumpleton
grahamd at dscpl.com.au
Tue Nov 8 04:04:35 EST 2005
On 08/11/2005, at 12:49 AM, Stephane Bortzmeyer wrote: > I have a Vampire 1.7 + mod_python 3.1.3 installation where the > ".vampire" file is apparently not loaded (for instance, the "handler > =" option seems ignored). The problem is that I do not find why! > > * The Apache Virtual Host has a "PythonOption VampireDefaultHandlers > On" > > * .vampire exists and is world-readable > > On another machine, with the same OS (Debian "sarge"), everything is > fine. > > So, what could I do to investigate? Is there a way to be absolutely > certain that ".vampire" is found and loaded? To confirm that the config file is being loaded at any point, introduce a syntax error into it. For example, add a first line to the configuration file of the form: [XXX If the config file is loaded at any point, you should get an error such as that include below. Mod_python error: "PythonHandler vampire" Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/site-packages/vampire/lookup.py", line 735, in _handler config = _configCache.loadConfig(req,file) File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/site-packages/vampire/config.py", line 246, in loadConfig config.read(file) File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/ConfigParser.py", line 263, in read self._read(fp, filename) File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/ConfigParser.py", line 456, in _read raise MissingSectionHeaderError(fpname, lineno, `line`) MissingSectionHeaderError: File contains no section headers. file: /Users/grahamd/Sites/vampire/.vampire, line: 1 '[XXX\n' If the file isn't even loaded, then could possibly be a file permission or ownership issue. Ie., the user that Apache runs as can't read the file. It is probably unlikely that Apache can't read the directory itself as would imagine that would cause other more obvious problems as Apache wouldn't be able to derive what the target of the URL should be matched to and would return 404. Next thing to realise is that if "handler" is what you intend to be used, then there is an expectation that there is no extension on the URL being used. You have been using Vampire long enough probably to know that though. Next thing is to delve into what is in the config which is being found. To do that, stick the following .py file in directory where .vampire file is located, or some subdirectory which you expect to inherit the .vampire file from the parent directory. from mod_python import apache import vampire def handler(req,raw=None): req.content_type = 'text/plain' for option in req.get_options().keys(): req.write('%s = %s\n'%(option,req.get_options().get(option))) req.write('\n') config = vampire.loadConfig(req,'.vampire') for option in config.defaults(): req.write('%s = %s\n'%(option,config.defaults().get(option))) req.write('\n') for section in config.sections(): req.write('[%s]\n'%section) for option in config.options(section): req.write(' %s = %s\n'%(option,config.get(section,option,raw=raw))) req.write('\n') return apache.OK If this is called "config.py" accessing as URL ".../config" using the .vampire file with Vampire itself as an example, expect to see: VampireDefaultHandlers = On VampireDirectoryIndex = index.html __config_root__ = /Users/grahamd/Sites/vampire __handler_root__ = /Users/grahamd/Sites/vampire __baseurl_abs__ = /~grahamd/vampire __config_file__ = /Users/grahamd/Sites/vampire/.vampire __config_mtime__ = 1131438786 __baseurl_rel__ = . [Handlers] handler_html = /Users/grahamd/Sites/vampire/layouts/skidoo.py layouts_root = /Users/grahamd/Sites/vampire/layouts [Settings] website_home = ./../.. document_root = /Users/grahamd/Sites/vampire vampire_home = . styles_home = ./styles Using instead the URL ".../config?raw=1", expect to see: VampireDefaultHandlers = On VampireDirectoryIndex = index.html __config_root__ = /Users/grahamd/Sites/vampire __handler_root__ = /Users/grahamd/Sites/vampire __baseurl_abs__ = /~grahamd/vampire __config_file__ = /Users/grahamd/Sites/vampire/.vampire __config_mtime__ = 1131438786 __baseurl_rel__ = . [Handlers] handler_html = %(layouts_root)s/skidoo.py layouts_root = %(__config_root__)s/layouts [Settings] website_home = %(__baseurl_rel__)s/../.. document_root = %(__config_root__)s vampire_home = %(__baseurl_rel__)s styles_home = %(__baseurl_rel__)s/styles If you don't see the config file you expect then only next step I can think of would be to modify vampire/config.py source code in Vampire package itself to log messages about what file it is looking for and in what locations. See what you come up with with that first. If all that looks okay and URL being used is correct, ie., no extension and "handler" in "Handlers" section isn't being used let me know and I will see what else I can suggest. Will probably need to see what configuration you are using at that point and how directories are structured and what URL is targeting. Graham
|