PythonInitHandler does not work in .htaccess file.
--------------------------------------------------

                 Key: MODPYTHON-209
                 URL: http://issues.apache.org/jira/browse/MODPYTHON-209
             Project: mod_python
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.10, 3.1.4, 3.3
            Reporter: Graham Dumpleton


The documentation says this about the PythonInitHandler:

  This handler is the first handler called in the request processing phases 
that is allowed
  both inside and outside .htaccess and directory.

  This handler is actually an alias to two different handlers. When specified 
in the main config
  file outside any directory tags, it is an alias to PostReadRequestHandler. 
When specified
  inside directory (where PostReadRequestHandler is not allowed), it aliases to 
PythonHeaderParserHandler.

I believe the idea is that instead of having to know whether one should use 
PythonPostReadRequestHandler or PythonHeaderParserHandler dependent on whether 
you are setting up configuration in either main Apache configuration or 
.htaccess file, you just use the PythonInitHandler directive instead in either 
the main Apache configuration or the .htaccess file and it will called as 
appropriate for either phase automatically based on where it was used.

Problem is that it cannot work in the .htaccess file.

This is because the code for PythonPostReadRequestHandler says:

static int PythonPostReadRequestHandler(request_rec *req) {
    int rc;

    /* run PythonInitHandler */
    rc = python_handler(req, "PythonInitHandler");
    apr_table_set(req->notes, "python_init_ran", "1");
    if ((rc != OK) && (rc != DECLINED))
        return rc;

    return python_handler(req, "PythonPostReadRequestHandler");
}

and that for PythonHeaderParserHandler says:

static int PythonHeaderParserHandler(request_rec *req) {
    int rc;

    /* run PythonInitHandler, if not already */
    if (! apr_table_get(req->notes, "python_init_ran")) {
        rc = python_handler(req, "PythonInitHandler");
        if ((rc != OK) && (rc != DECLINED))
            return rc;
    }
    return python_handler(req, "PythonHeaderParserHandler");
}

The issue is that the table note called 'python_init_ran' is always set in the 
first function regardless of whether there was actually a registered 
PythonInitHandler that got called as part of the PythonPostReadRequestHandler 
phase. Thus, there will never be an opportunity for a PythonInitHandler 
registered in a .htaccess file to get called.

The whole idea of the PythonInitHandler is possibly a bit suspect and since the 
idea was copied from mod_perl, a look should be made to see what mod_perl 2.0 
does and whether they still have it.

One thing that is a bit confusing is why one would want a single alias for 
these two different phases, especially since they aren't even adjacent within 
the processing sequence. Specifically the Apache phases include:

    "postreadrequesthandler"
    "transhandler"
    "maptostoragehandler" # not implemented by mod_python
    "headerparserhandler"

Thus, the two phases are quite separate and the PythonTransHandler comes 
between them. Thus, why have them use the same name????

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to