[mod_python] Serving files via mod_python

Hugo van der Merwe s13361562 at bach.sun.ac.za
Mon May 20 21:05:31 EST 2002


Hello,

I want to use mod_python to control what files can be downloaded by
whom, and to log such file transfers (with my own code). One possibility
is also to convert some files' contents on the fly.

I am currently using:

f = open(filename, "r")
while 1:
  data = f.read(1048576)
  if data = "": break
  req.write(data)

It seems to work fine. I just wonder if this is bad (performance wise, I
wonder what the best "size" would be, instead of 1M). These are
potentially *large* files I'm dealing with, things like cd images. At a
later date I guess I'll have to figure out how to do download resuming,
etc. I'm sure Apache does a better job of this, maybe I should rather
let Apache handle it, how can I do this while controlling it all from
modPython? I guess I could just define a PythonAuthenHandler, and let
Apache do the actual serving? Does the PythonAuthenHandler have full
access to just about everything a normal handler would? (URL, etc.)

If there was some way to give Apache a file handle or something like
that, from which it should serve the data...

Thanks,
Hugo van der Merwe



More information about the Mod_python mailing list