Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
malcolmt committed May 14, 2007
1 parent 4c34343 commit 03b86ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions django/utils/functional.py
Expand Up @@ -32,6 +32,8 @@ def __init__(self, args, kw):
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
Expand All @@ -47,6 +49,9 @@ def __wrapper__(*args, **kw):
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)
Expand Down

0 comments on commit 03b86ea

Please sign in to comment.