[mod_python] Re: [patch] vampire 1.1 remove unknown query variables

Graham Dumpleton grahamd at dscpl.com.au
Tue Oct 19 20:05:44 EDT 2004

On Oct 19 16:50, Johannes Erdfelt <johannes at erdfelt.com> wrote:
> Subject: Re: [patch] vampire 1.1 remove unknown query variables
> On Tue, Oct 19, 2004, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> > On Oct 19 13:56, Johannes Erdfelt <johannes at erdfelt.com> wrote:
> > >
> > > Subject: [patch] vampire 1.1 remove unknown query variables
> > >
> > > +    # We definately had some missing variables, let's let the user know
> > > +    req.content_type = "text/plain"
> > > +    req.status = apache.HTTP_INTERNAL_SERVER_ERROR
> > > +    req.send_http_header()
> > > +    req.write("Call is missing these variables: %s\n" % ", ".join(missing))
> > > +
> > > +    return apache.OK
> > 
> > I am a bit wary of directly generating an error response from this point in
> > the code.
> > 
> > What may be better is to raise a Python RuntimeWarning exception with the
> > description of the problem. This will cause mod_python to still return an
> > internal server error, but one where the details would only be visible when
> > PythonDebug option is set to On. The error would also be logged into the
> > log file automatically.
> That's a good point. Some people may not want this level of information
> to be returned to the user.
> On the other hand, I hate Internal Server Error messages (and shame on
> me for returning that as the error too :). They are kind of misleading
> in this case because the error isn't internal to the server, but in the
> request from the client.
> To some extent, the error code that is returned is a problem since it
> causes alarms with my log analysis scripts, but I'm more concerned with
> the message that is returned.

Well, it could still be done in Vampire as you propose, but simply have it
honour the PythonDebug setting. It may be more approriate to return a
in this case.

Unfortunately the mod_python routine for generating internal server
error responses, with details as appropriate if PyhonDebug is on isn't a
generically usable routine that could be used to do it and I don't think
it allows an alternate status anyway. Vampire could provide such a
generic routine that might even also be usable in some way from a user
content handler when they want to return errors, but with a message
when PythonDebug is set.

Graham Dumpleton (grahamd at dscpl.com.au)

More information about the Mod_python mailing list