[mod_python] finding length of user file before uploading-revisit

Kevin Albright albrightk at gmail.com
Tue Jul 18 12:45:09 EDT 2006


I am attempting Graham Dumpleton's solution (April 2006) to prevent uploads
of files that are deemed to large with the suggested handler he posted
(shown below).  I have the PythonFixupHandler listed before
mod_python.publisher as instructed in httpd.conf.  Trying this method, I
receive the message "upload too big" returned but only after finishing the
upload of the offending file (I am assuming that the Fixup handler is not
preventing publisher from uploading).  I appreciate any help or insight
others can offer.  Many thanks, Kevin

>>*   PythonFixupHandler check_for_large_uploads
*>>*   # check_for_large_uploads.py
*>>*   from mod_python import apache
*>>*   UPLOAD_LIMIT = 1000000
*>>*   def fixuphandler(req):
*>>*     length = int(req.headers_in.get("Content-Length", "0"))
*>>*     if length >= UPLOAD_LIMIT:
*>>*       req.content_type = 'text/plain'
*>>*       req.status = apache.HTTP_BAD_REQUEST
*>>*       req.write('upload too big\n')
*>>*       return apache.DONE
*>>*     return apache.OK*

>If you are using mod_python.publisher you choices thus are:

>
><Directory myserver/www/uploads>
>     SetHandler mod_python
>     PythonFixupHandler check_for_large_uploads
>     PythonHandler mod_python.publisher
>     ...
></Directory>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060718/1e7b22af/attachment.html


More information about the Mod_python mailing list