I'd prefer explicit mapping in a way:

for methodname in ('seek', 'tell', 'readline'):
  # Map methodname File.file.<method> to django's File.<method>

1] You easy way to control mapping
2] You don't repeat yourself
3] Explicit and readable system
4] You avoid you're "queasy feeling"


BTW: What if python file object will have some method, that changes
file's state (open/closed) or mode (read/write). In that case implicit
mapping could change File._file.mode without affecting django's
File._mode and File._name.




On Sat, Jan 31, 2009 at 12:27 AM, Todd O'Bryan <toddobr...@gmail.com> wrote:
>
> On Fri, Jan 30, 2009 at 5:08 PM, Ludvig Ericson
> <ludvig.eric...@gmail.com> wrote:
>>
>> On Jan 30, 2009, at 22:19, Todd O'Bryan wrote:
>>>
>>> I'm not sure I understand this. If you try to call a file-like method
>>> or access a file-like attribute on an UploadedFile, it would either do
>>> the right thing or you'd get an error saying that UploadedFile doesn't
>>> support it. Neither of those seems terribly astonishing.
>>
>> And then you get an AttributeError which moans about some entirely
>> different object, inside a foreign method. I know, you can weed it
>> out, but I'm not alone in staring at the asyncore exceptions.
>
> Oh, that would be *awful*. You don't just send attribute access
> requests off to the backing object and cross your fingers. If I
> implement it, I'd try the attribute access on self._file and if it
> doesn't work, return a reasonable error message from the UploadedFile
> class rather than the error message from the backing object. Would
> that make this any more palatable?
>
>> The __getattr__-approach also has the side-effect of dispatching all
>> missing attribute accesses, which could result in oddities for other
>> reasons. Not that I can think of one, but it could be a source of
>> subtle bugs.
>
> That's what I'm mostly worried about. I can't think of any things that
> would obviously happen, but Python's indirection facility has gotten
> me in trouble more often than I like to admit. Anybody have any
> concrete examples of what could go wrong, rather than a generalized
> queasy feeling (which I must admit I share)? :-)
>
> Todd
>
> >
>



-- 
------------------------------------------------------
Ales Zoulek
+420 604 332 515
Jabber: a...@jabber.cz
ICQ: 82647256
------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to