Django

Code

Changeset 5344

Show
Ignore:
Timestamp:
05/26/07 01:39:10 (1 year ago)
Author:
mtredinnick
Message:

unicode: Fixed proxy.str() handling. So gettext_lazy() will work more
naturally now.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/django/utils/functional.py

    r5314 r5344  
    3434                    setattr(self, k, self.__promise__(resultclass, k, v)) 
    3535            if unicode in resultclasses: 
    36                 setattr(self, '__unicode__', self.__unicode_cast) 
     36                self.__unicode__ = self.__unicode_cast 
     37            self._delegate_str  = str in resultclasses 
    3738 
    3839        def __promise__(self, klass, funcname, func): 
     
    5253        def __unicode_cast(self): 
    5354            return self.__func(*self.__args, **self.__kw) 
     55 
     56        def __str__(self): 
     57            # As __str__ is always a method on the type (class), it is looked 
     58            # up (and found) there first. So we can't just assign to it on a 
     59            # per-instance basis in __init__. 
     60            if self._delegate_str: 
     61                return str(self.__func(*self.__args, **self.__kw)) 
     62            else: 
     63                return Promise.__str__(self) 
    5464 
    5565    def __wrapper__(*args, **kw):