Audrius Kažukauskas wrote:
> On Fri, 2008-09-26 at 12:52:49 -0500, Ian Bicking wrote:
>> Audrius Kažukauskas wrote:
>>> You can do this somewhere in the beginning of paste.request module:
>>>
>>>   class MyFieldStorage(cgi.FieldStorage):
>>>     def make_file(): ... # Your code here
>>>
>>>   cgi.FieldStorage = MyFieldStorage
>>>
>>> It's a bit hacky, but it works (I tested it myself).
>>>
>>> BTW, maybe Paste author (it's Ian Bicking, right? :-) could come with
>>> more convenient way (public API calls?) to control this without the need
>>> of code modification in paste.request?
>> That's possible, but looking at the source of tempfile it uses the 
>> environmental variables $TMPDIR, $TEMP, and $TMP to figure out where to 
>> put temporary files, and setting those values should be easy in 
>> comparison to these other techniques.  Patching cgi.FieldStorage would 
>> allow for more fine-grained control (just where uploads go, instead of 
>> all temp files), but I'm not sure how important that really is.
> 
> OK, my use case:
> 
> Web app lets upload big files (let's say, up to 100 MiB) and keeps them
> for some time.  Right now they go to /tmp and it could be changed with
> environmental variables, as you said.  But the problem is that files
> created by tempfile.TemporaryFile can only be read from or written to
> (at least in POSIX or Cygwin systems).  You can't *move* them, only copy
> from them.  And the saddest part is, they disappear when closed.  Hence
> you must write data to some other file.  So information is copied twice:
> when uploading to the temporary file and after that to some permanent
> file.  If web app is used more intensively or files are getting bigger,
> this is inefficient.

It's not high on my list of issues, but I can see your use case. 
Putting files in the right place to start with seems infeasible, but 
being able to move them around later seems reasonable (and controlling 
what directory they are written to, so you can keep them on the same 
device).  I'd accept a patch, probably to WebOb.

Somewhat relatedly, someone recently did a rewrite of cgi, that might be 
worth thinking about: 
http://mail.python.org/pipermail/web-sig/2008-September/003587.html

-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to