On Thu, Jan 29, 2009 at 11:14 PM, Todd O'Bryan <toddobr...@gmail.com> wrote: > On Thu, Jan 29, 2009 at 9:28 PM, Malcolm Tredinnick > <malc...@pointy-stick.com> wrote: >> >> On Thu, 2009-01-29 at 15:40 -0500, Todd O'Bryan wrote: >>> I'm trying to validate an uploaded csv file, so I want to read the >>> first line of text and if it's not the right format, send an error >>> message. Unfortunately, neither InMemoryUploadedFile nor >>> TemporaryUploadedFile have the readline() method. >>> >>> Was that an oversight (in which case I'll create a two-line patch and >>> submit it--both StringIO and temp files support the method) or a >>> design decision with a good reason? >> >> It's a flaw in Python: what an object needs to be "file-like" is not >> well defined. Different users require different things. A file doesn't >> really need a readlines() method, except when it does, etc. >> >> There's about half a dozen tickets open for "add X, Y or Z" to the file >> stuff, so look through those first. >> >> Regards, >> Malcolm >> > > OK. I proxied every file-like object method or attribute listed in the > Python docs. If something doesn't work now it's because the object > that backs the UploadedFile doesn't support it, not because we forgot > to provide a proxy to it. > > http://code.djangoproject.com/ticket/9404 >
OK, after I did this, I was lying in bed and had the following revelation. Would there be anything terribly wrong with just using __getattr__ in UploadedFile to forward all attribute requests that the UploadedFile can't process to self._file, the file-like object that would be backing it? That way, you get access to all the features of the underlying file without much overhead in the UploadedFile. Thoughts? Todd --~--~---------~--~----~------------~-------~--~----~ 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 django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---