Sean True
seant at webreply.com
Fri Jul 6 12:34:27 EST 2001
With a little bit of help from Grisha, I got past my first problem (I needed a writable req.uri) and am onto a second one. I stripped out the following handlers from a much larger system, and they reproduce the problem. The production handler (handler) attempts to do a lookup_uri on the inbound URI. If there is no translation handler called for in the conf file, all is well, and the lookup works. If there is a translation handler declared using PythonTransHandler, the Transhandler gets called twice, and the server process appears to go into a loop -- never exits the production handler. I'm suspecting that there is a reentrancy issue here of some sort, but the Apache code specifically suggests calling lookup_uri() to get the mapping of "/" to filename, instead of using document_root(). Comments on the rules of when one can and can't call lookup_uri() would be welcome. -- Sean Configuration: # Connections for general test site <VirtualHost www.foo.com> DocumentRoot /usr/local/apache/htdocs/www.foo.com ServerName www.foo.com AddHandler python-program .phtml PythonInterpreter xphtml PythonHandler phtml.xphtml PythonTransHandler phtml.xphtml </VirtualHost> xphtml.py: from mod_python import apache from phtmllog import log, logIO def transhandler(req): log("transhandler "+`req.uri`) return apache.DECLINED def handler(req): log("lookup_uri "+req.lookup_uri(req.uri).filename) return apache.OK requestobject.c code for lookup_uri: /** ** request.lookup_uri(request self, uri) ** * An interface to the ap_lookup_uri function. */ static PyObject * req_lookup_uri(requestobject *self, PyObject *args) { const char *uri; request_rec *req; if (! PyArg_ParseTuple(args, "s", &uri)) return NULL; req = (request_rec *)ap_sub_req_lookup_uri(uri,self->request_rec); if (! req) { Py_INCREF(Py_None); return Py_None; } else { return MpRequest_FromRequest(req); } } ... {"lookup_uri", (PyCFunction) req_lookup_uri, METH_VARARGS}, { NULL, NULL } /* sentinel */ }; ...
|