Since it seems like Django is gearing up for a 1.0 release soon, I
think the reopened ticket#7593 should be addressed.  Right now, there
is no standard way to access an UploadedFile as a python file object.

Suppose you have a form and want to process a zip file, for example.
You'd want to unit test it with a SimpleUploadedFile instance, so you
access the 'file' member (which, by the way, is undocumented).

Now your unit test works and it'll happen to also work for
InMemoryUploadedFile, but it'll fail for TemporaryUploadedFile (which
has a '_file' member).  If instead you try to treat the uploaded file
as a file object itself, it'll work for TemporaryUploadedFile (except
that it's missing the tell() function and a few others), but will fail
your unit tests and for InMemoryUploadedFile.

In my opinion, either all subclasses of UploadedFile should act as
python file objects or they should all simply provide the 'file'
member and at least be consistent.  The latter is simpler, so I
consider it to be the better option.

As it is, for those of us who need to process large incoming files, we
either need to reopen it (which doesn't work on some filesystems, e.g.
any windows filesystem) or we need to save it to the hard drive again
in a separate location.

Thanks,
Jonathan Hseu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to