diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-14 19:04:06 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-14 19:04:06 +0000 |
| commit | 03b86ea12dc7f0caf805b7fc0871413b7a2c57da (patch) | |
| tree | 3ab3b2878c3a987e14f70f2370cc74930497c9cb | |
| parent | 4c34343e178d9c46e7f037ecd34463905f69b9cb (diff) | |
unicode: Fixed #4292 -- Added support for __unicode__ to lazy() objects.
Thanks, Ivan Sagalaev.
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5239 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/utils/functional.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py index 0c31c1f375..8127ad8407 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -32,6 +32,8 @@ def lazy(func, *resultclasses): self.__dispatch[resultclass] = {} for (k, v) in resultclass.__dict__.items(): setattr(self, k, self.__promise__(resultclass, k, v)) + if unicode in resultclasses: + setattr(self, '__unicode__', self.__unicode_cast) def __promise__(self, klass, funcname, func): # Builds a wrapper around some magic method and registers that magic @@ -47,6 +49,9 @@ def lazy(func, *resultclasses): self.__dispatch[klass][funcname] = func return __wrapper__ + def __unicode_cast(self): + return self.__func(*self.__args, **self.__kw) + def __wrapper__(*args, **kw): # Creates the proxy object, instead of the actual value. return __proxy__(args, kw) |
