On 23 March 2010 07:29, Deron Meranda <[email protected]> wrote: > Is it possible for a WSGI application to decide it wants > to decline being a handler; from the Apache perspective? > I know the WSGI spec itself doesn't provide for this,
Correct, the WSGI interface specification doesn't allow any such thing, it assumes that the WSGI application will always return the complete response. > but is there some sort of exception or something that > could do this with mod_wsgi? I have looked at that before and am looking at it again at the moment. Ideally I would like to see the WSGI specification support the concept of declined by a WSGI application/component being able to return None, without having called start_response() as indicating that it declines to service the request. This has application within WSGI stacks as well as at the server boundary. For within a WSGI application instead of having to nest WSGI components to allow a measure of logic, one can serialise calling of components at a single level. My original idea of using None as return type for this got morphed by Ian Bicking into paste.cascade (http://pythonpaste.org/modules/cascade.html) but that means you have to use up a HTTP status code to indicate DECLINED making it harder for a component to actually use that status. The alternative to returning None which can work within bounds of WSGI specification is that the WSGI environ hold a callable called 'apache.decline_request' which when called returns a special iterable object, like 'wsgi_file_wrapper' does. This special iterable object would be detected by mod_wsgi and cause DECLINED to be returned from underlying handler. I don't like this because it necessitates still having to call start_response(). Also, that iterable could be consumed by an intermediary in the WSGI stack and effectively vanish. Thus, I have to contemplate whether I again step outside of WSGI and at least via optional directive, allow returning None to indicate DECLINED. > Obviously this would have to happen before the call > to the response_handler callback; because that is > the point of no return. In Apache, even the content handler can return declined. You can in mod_python for example do: from mod_python import apache def handler(req): req.filename = '/etc/services' req.finfo = apache.stat(req.filename, apache.APR_FINFO_MIN) return apache.DECLINED By the content handler returning DECLINED but setting up filename and finfo for that file, it will fall through to default Apache handler, which will then serve up that file. The handler may have to setup up stuff such as content type, response headers etc, but can be done. One doesn't have that ability in WSGI to affect the original request object though. Graham -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
