diff options
| author | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-21 10:41:54 +0000 |
|---|---|---|
| committer | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-21 10:41:54 +0000 |
| commit | e4e28d907aee9f0e3977e2c6237406d7746c5719 (patch) | |
| tree | 9d7538e159d79bc4350190f301672f3c9ad9d613 /django/utils | |
| parent | a49fa746cdc056f0b660f47fbc55aa43fcd54bcc (diff) | |
fixes #753 - ValidationError and CriticalValidationError now accept both strings and promises from gettext_lazy
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1328 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/functional.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py index f2ea12b1b2..69aeb81850 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -3,6 +3,14 @@ def curry(*args, **kwargs): return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) return _curried +class Promise: + """ + This is just a base class for the proxy class created in + the closure of the lazy function. It can be used to recognize + promises in code. + """ + pass + def lazy(func, *resultclasses): """ Turns any callable into a lazy evaluated callable. You need to give result @@ -10,7 +18,7 @@ def lazy(func, *resultclasses): the lazy evaluation code is triggered. Results are not memoized; the function is evaluated on every access. """ - class __proxy__: + class __proxy__(Promise): # This inner class encapsulates the code that should be evaluated # lazily. On calling of one of the magic methods it will force # the evaluation and store the result. Afterwards, the result |
