diff options
| author | Justin Bronn <jbronn@gmail.com> | 2007-10-26 20:47:20 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2007-10-26 20:47:20 +0000 |
| commit | 4ffbddf92d89c3b31cef90043721184a501cd454 (patch) | |
| tree | db8131d40b0a5437270a6b1e8d579113ab3508e8 /django/utils/functional.py | |
| parent | f66ee9d0065838a0f6c9c76203a775a78446cdf7 (diff) | |
gis: Merged revisions 6525-6613 via svnmerge from [repos:django/trunk trunk].
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6615 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/functional.py')
| -rw-r--r-- | django/utils/functional.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py index f4580e7bd5..e0c862b0b7 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -53,7 +53,11 @@ def lazy(func, *resultclasses): self._delegate_unicode = unicode in resultclasses assert not (self._delegate_str and self._delegate_unicode), "Cannot call lazy() with both str and unicode return types." if self._delegate_unicode: - self.__unicode__ = self.__unicode_cast + # Each call to lazy() makes a new __proxy__ object, so this + # doesn't interfere with any other lazy() results. + __proxy__.__unicode__ = __proxy__.__unicode_cast + elif self._delegate_str: + __proxy__.__str__ = __proxy__.__str_cast def __promise__(self, klass, funcname, func): # Builds a wrapper around some magic method and registers that magic @@ -72,14 +76,8 @@ def lazy(func, *resultclasses): def __unicode_cast(self): return self.__func(*self.__args, **self.__kw) - def __str__(self): - # As __str__ is always a method on the type (class), it is looked - # up (and found) there first. So we can't just assign to it on a - # per-instance basis in __init__. - if self._delegate_str: - return str(self.__func(*self.__args, **self.__kw)) - else: - return Promise.__str__(self) + def __str_cast(self): + return str(self.__func(*self.__args, **self.__kw)) def __cmp__(self, rhs): if self._delegate_str: |
