| Graham Dumpleton 2006-02-21, 8:45 pm |
| Grisha wrote ..
>
> If I understand this correctly, then +1.
>
> ...though I'm wondering if anyone will actually try to do something as
> arcane as dynamicaly registering non-content handers? :-)
I agree, it might not be a totally realistic scenario, but then now that
I have checked in a change to make req.handler writable, the system
is becoming flexible enough that it may actually be reasonable to do
it for some reason.
Specifically, with the change to make req.handler writable, instead of
using SetHandler/AddHandler to have mod_mime internally set
req.handler to "mod_python", you could define your own type handler
which did it.
def typehandler(req):
if os.path.splitext(req.filename)[1] == ".py":
req.handler = "mod_python"
req.add_handler("PythonHandler","mod_python.publisher")
return apache.OK
return apache.DECLINED
You might even at the same time want to register a fixup handler
to do stuff prior to the response phase being run:
def typehandler(req):
if os.path.splitext(req.filename)[1] == ".py":
req.handler = "mod_python"
req.add_handler("PythonFixupHandler","manage_session_object")
req.add_handler("PythonHandler","mod_python.publisher")
return apache.OK
return apache.DECLINED
For example, you might introduce a fixup handler which ensures that
a session object is created and put in req.session. This is a lot cleaner
than what most people do, which is to put a call to the session manager
code in every single published function.
Graham
[vbcol=seagreen]
> On Tue, 21 Feb 2006, Jim Gallacher wrote:
>
> on
> in
> OK
> it
> keep
> to
> in
> now.
> using
> as
> had
> them
> call
> No
> All
|