Gregory Trubetskoy
grisha at modpython.org
Mon Sep 11 14:37:25 EST 2000
On Mon, 11 Sep 2000, Rich Salz wrote: > I don't fully understand how mod_python does sub-interpreters; I'll have > to reread the docs. The things you should read are: The top of http://www.modpython.org/live/mod_python-2.5/doc/pythonapi.html as well as http://www.modpython.org/live/mod_python-2.5/doc/directives.html#PythonInterpreter http://www.modpython.org/live/mod_python-2.5/doc/directives.html#PythonInterpPerDirectory http://www.modpython.org/live/mod_python-2.5/doc/directives.html#PythonInterpPerServer > It never occured to me that there could/would be different interps for > each handler. This would happen for example if authentication is handled by an application entirely different from the one creating content. If your PyhtonAuthenHandler is in the httpd.conf file and the app is driven by a PythonHandler in an .htaccess file, you'd have the same request, but different handlers would have different suninterpreters. > I suggest that the docs make it more clear that the handlers are > "stateless". ...or make ways to retain state... :-) Here is a suggestion - if I provided a way to store a pointer to a Python object in notes - would that solve your problem? You create the object, then call some function that returns a string that you can store in notes. Then you can call another function that you pass that string and it will return the Python object. That way mod_python does not need to concern itself with the context in which the object is used, and you can pass the object between handlers. > For us, the cleanest thing is one interp/request, with no state kept > across requests. In most cases there would be one interp per request, or you can ensure it by using the PythonInterpreter directive. For example, sticking something like "PythonInterpreter MyOnlyInterpreter" into httpd.conf would make the whole server run under one interpreter. > That seems most like the "classic" apache processing model. Apache was designed with multiple users and multiple applications in mind. That's why it supports .htaccess files. Mod_python's subinterpreters extend that notion. You can have two different application with clashing module names run on the same server with no problems because they could be run in different subinterpreters. Or you can have two instances of the same application run in separate subinterpreters. Try that with mod_perl. Grisha
|