| Nicolas Lehuen 2006-02-21, 8:45 pm |
| +1
Excellent summary, Graham.
Maybe we could ask on the mod_pyhon mailing list who is stacking
non-content handlers, especially if registered dynamically, and for
what purpose ? This way we could make sure that no one actually relies
on the current cludgy behaviour.
But I agree with you, it's pretty sure that changing mod_python to
align with the standard Apache behaviour should not meet popular
disagreement, especially given the corner cases in which it really
matters .
Regards,
Nicolas
2006/2/22, Graham Dumpleton <grahamd@dscpl.com.au>:
> Grisha wrote ..
>
> 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] =3D=3D ".py":
> req.handler =3D "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] =3D=3D ".py":
> req.handler =3D "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
>
re[vbcol=seagreen]
s[vbcol=seagreen]
n[vbcol=seagreen]
eeds[vbcol=seagreen]
hat[vbcol=seagreen]
e[vbcol=seagreen]
oes[vbcol=seagreen]
on[vbcol=seagreen]
ime[vbcol=seagreen]
er[vbcol=seagreen]
s[vbcol=seagreen]
dler[vbcol=seagreen]
n[vbcol=seagreen]
iple[vbcol=seagreen]
d[vbcol=seagreen]
s[vbcol=seagreen]
rs[vbcol=seagreen]
at[vbcol=seagreen]
ning[vbcol=seagreen]
s[vbcol=seagreen]
ython[vbcol=seagreen]
at[vbcol=seagreen]
..[vbcol=seagreen]
ing[vbcol=seagreen]
..[vbcol=seagreen]
s[vbcol=seagreen]
>
|