diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-18 02:23:24 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-18 02:23:24 +0000 |
| commit | f4387422f0a556fb2469500fb9d408306bead02c (patch) | |
| tree | 2e682f6751c79c7dd301b28cd54b3109b19db25a /django/utils | |
| parent | 2126d41aba06b50a288cc6a516d4531ced998822 (diff) | |
unicode: Implemented comparisons between *_lazy() objects. comparing
ugettext_lazy() instances to each other now works, for example.
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5489 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/functional.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py index cd34809837..574f433fd5 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -64,6 +64,18 @@ def lazy(func, *resultclasses): else: return Promise.__str__(self) + def __cmp__(self, rhs): + if self._delegate_str: + s = str(self.__func(*self.__args, **self.__kw)) + elif self._delegate_unicode: + s = unicode(self.__func(*self.__args, **self.__kw)) + else: + s = self.__func(*self.__args, **self.__kw) + if isinstance(rhs, Promise): + return -cmp(rhs, s) + else: + return cmp(s, rhs) + def __mod__(self, rhs): if self._delegate_str: return str(self) % rhs |
