On Wednesday 14 October 2009 16:39:31 Luke Plant wrote:
> On Wednesday 14 October 2009 15:54:25 Russell Keith-Magee wrote:
> > > * the output of {{ user }} in a template will be different. I
> > > think this is acceptable, because only things like {{
> > > user.username }} are actually useful, apart from when
> > > debugging.
> >
> > I disagree. User.__unicode__() returns self.username, so {{ user
> > }} is a potentially useful (albeit non-specific) rendering
> > technique for user.
>
> OK, I'll fix that. I had thought that it returned
> "<User:username>", but that's repr(), not unicode().
Just to point out, to anyone who cares or gets confused by my patch:
There was a whole bunch of confusion in my original post. The output
of {{ user }} was never actually threatened.
I was mixing up unicode/repr/str in my testing, and assuming that they
would work the same way. LazyObject as it currently stands [1] will
proxy __unicode__ methods automatically, but not __repr__ and __str__,
although it does not have any special casing for any of them. This is
due to the fact that 'object' does not provide an implementation of
__unicode__, but does for the other two, and __getattr__ is only
triggered when that implementation is not found.
We should probably add that special casing for at least str, possible
unicode.
Luke
[1]
http://code.djangoproject.com/browser/django/trunk/django/utils/functional.py?rev=9945#L255
--
You meet a lot of smart guys with stupid wives, but you almost
never meet a smart woman with a stupid husband. (Erica Jong)
Luke Plant || http://lukeplant.me.uk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---