|
Daniel J. Popowich
dpopowich at mtrsd.k12.ma.us
Thu Feb 5 10:32:23 EST 2004
Gregory (Grisha) Trubetskoy writes:
>
>
> On Tue, 13 Jan 2004, Daniel J. Popowich wrote:
>
> > In most of my mod_python apps if a request comes in for a file that I
> > don't want to handle, let's say an image file, foo.gif, I raise
> > apache.SERVER_RETURN with a value of apache.DECLINED. Apache then
> > handles the request and sends in the header:
> >
> > Content-Type: image/gif
> >
> > However, I now have an app that wants to live in a <Location ...>
> > directive so returning apache.DECLINED doesn't work: apache has no
> > other means of handling the request so it returns a 404 error.
>
> I am not sure I understand why that is... - what's the difference between
> a request in <Location ...> and any other request?
>
<Location ...> directives live in url space, completely outside from
the filesystem. I have my app configured like this:
<Location /site>
SetHandler python-program
PythonHandler ...
...
</Location>
When requests come in, such as http://myserver/site/foo/bar, my
handler will use 'foo/bar' to determine what it sends back to the
client and, generally, use the pathinfo as a relative path from a data
directory configured, purposefully, outside of DocumentRoot. So, how
do I set content-type correctly for content I don't generate, ie,
images?
If my app was <Directory> based, I could raise apache.SERVER_RETURN
with apache.DECLINED; apache would have means to find the file and "do
the right thing," but inside <Location> there is NO filesystem, thus
my 404 error.
> > My only means of recourse seems to be something like this:
> >
> > if NOT_HANDLING_PAGE:
> > req.write(open(filename).read())
>
> As a sidenote, if you're using 3.1.2b, you should check out
> req.sendfile().
Yes, I'm using 3.1.2b. I'll check it out, it may be just what I'm
looking for.
Thanks,
Daniel
|