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().
> My only other comment is about ContextLazyObject - is this really
> something that is specific to Context objects? Although we don't
> have any other use for it right now, it strikes me as a more
> general functional utility for deferring access to an object,
> rather than something specific for templates.
At the moment it's pretty general - it's just a thin layer on top of
LazyObject that allows a callable to be passed in. But I don't want
to advertise it as a general solution for deferred access to
attributes because:
* LazyObject was only created to support dynamic settings really.
(i.e. where you are not using a settings file). It might have lots
of corner cases where it's really not appropriate to be used.
* There might be custom fixes we need for this use case. For example,
so far there is the need to add __unicode__. I'd like to be sure
I can fix these bugs, which might be harder if people start using
it for different things. Adding __unicode__ to LazyObject, for
instance, might make debugging of dynamic settings more difficult
* I think 'lazy' is a better solution in general. It just
unfortunately is not easy to use in this case.
If people find other uses for it, almost all the functionality is in
LazyObject anyway, which is as generic as it sounds.
Luke
--
"You'll be glad to know, I'm going to donate all the snot I sneeze
to hospitals for mucus transfusions." (Calvin and Hobbes)
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
-~----------~----~----~----~------~----~------~--~---