[mod_python] Re: [Vampire] ".vampire" not loaded but I do not see why

Graham Dumpleton grahamd at dscpl.com.au
Tue Nov 8 04:32:19 EST 2005


On 08/11/2005, at 8:10 PM, Stephane Bortzmeyer wrote:

> On Tue, Nov 08, 2005 at 08:04:35PM +1100,
>  Graham Dumpleton <grahamd at dscpl.com.au> wrote
>  a message of 157 lines which said:
>
>> To confirm that the config file is being loaded at any point, 
>> introduce
>> a syntax error into it.
>
> I tried it and there is no error and no stack trace.
>
>> 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.
>
> The file is world-readable and the directory also (Apache can read the
> Python files).
>
> I'll try the rest soon, thanks.

Apply the following patch to Vampire and reinstall. You can then track
through log messages in Apache error log file and see if where it is
looking makes sense.

Index: software/vampire/config.py
===================================================================
--- software/vampire/config.py  (revision 238)
+++ software/vampire/config.py  (working copy)
@@ -74,6 +74,8 @@

    def _search(self,req,name):

+    req.log_error("name = %s"%name)
+
      result = {
        "__handler_root__" : "",
        "__config_root__" : "",
@@ -99,6 +101,8 @@

      # Couldn't determine upper bounds of search.

+    req.log_error("handler_root [1] = %s"%handler_root)
+
      if handler_root is None:
        return result

@@ -119,6 +123,8 @@

      handler_root = posixpath.normpath(handler_root)

+    req.log_error("handler_root [2] = %s"%handler_root)
+
      # Now search back up directories for file.

      result["__handler_root__"] = handler_root
@@ -135,6 +141,8 @@
      else:
        config_root = posixpath.dirname(req.filename)

+    req.log_error("config_root = %s"%config_root)
+
      offset = ""

      if req.path_info and req.path_info != '/':
@@ -151,6 +159,8 @@

        config_file = posixpath.join(config_root,name)

+      req.log_error("config_file = %s"%config_file)
+
        if os.path.exists(config_file):
          config_root = posixpath.normpath(config_root)
          baseurl_abs = posixpath.normpath(baseurl_abs)


Example output where URL is against same directory .vampire file
is held:

[Tue Nov 08 20:25:23 2005] [error] [client 127.0.0.1] name = .vampire
[Tue Nov 08 20:25:23 2005] [error] [client 127.0.0.1] handler_root [1] 
= /Users/grahamd/Sites/vampire/
[Tue Nov 08 20:25:23 2005] [error] [client 127.0.0.1] handler_root [2] 
= /Users/grahamd/Sites/vampire
[Tue Nov 08 20:25:23 2005] [error] [client 127.0.0.1] config_root = 
/Users/grahamd/Sites/vampire
[Tue Nov 08 20:25:23 2005] [error] [client 127.0.0.1] config_file = 
/Users/grahamd/Sites/vampire/.vampire

Where it is in a subdirectory:

[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] name = .vampire
[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] handler_root [1] 
= /Users/grahamd/Sites/vampire/
[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] handler_root [2] 
= /Users/grahamd/Sites/vampire
[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] config_root = 
/Users/grahamd/Sites/vampire/articles
[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] config_file = 
/Users/grahamd/Sites/vampire/articles/.vampire
[Tue Nov 08 20:29:13 2005] [error] [client 127.0.0.1] config_file = 
/Users/grahamd/Sites/vampire/.vampire

You can see how it tracks back up the directory hierarchy looking for 
the
config file, stopping when it gets to handler_root.

Especially make sure that handler_root is even correct. There is code in
their already to work around a mod_python bug, but maybe there are still
some cases it doesn't work correctly.

Graham



More information about the Mod_python mailing list