summaryrefslogtreecommitdiff
path: root/django/utils/functional.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-06 22:22:02 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-06 22:22:02 +0000
commite19c9ccfcbd5b240c170df4b39a04af118d26e52 (patch)
tree8c9f830c1ab6312d5f808ef7c71dd5254ab1c556 /django/utils/functional.py
parentb14a50bb35baae5cb058190bd1b5c38eef74ad82 (diff)
Reworded docstrings and settings documentation from [1068]
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/functional.py')
-rw-r--r--django/utils/functional.py51
1 files changed, 16 insertions, 35 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 2b3ca8293e..f2ea12b1b2 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -4,24 +4,17 @@ def curry(*args, **kwargs):
return _curried
def lazy(func, *resultclasses):
-
"""
- lazy turns any callable passed in into a lazy evaluated callable.
- you need to give result classes or types - at least one is needed
- so that the automatic forcing of the lazy evaluation code is
- triggered. Results are not memoized - the function is evaluated
- on every access.
+ Turns any callable into a lazy evaluated callable. You need to give result
+ classes or types -- at least one is needed so that the automatic forcing of
+ the lazy evaluation code is triggered. Results are not memoized; the
+ function is evaluated on every access.
"""
-
class __proxy__:
-
- """
- This inner class encapsulates the code that should be evaluated
- lazyly. On calling of one of the magic methods it will force
- the evaluation and store the result - afterwards the result
- is delivered directly. So the result is memoized.
- """
-
+ # 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
+ # is delivered directly. So the result is memoized.
def __init__(self, args, kw):
self.__func = func
self.__args = args
@@ -31,35 +24,23 @@ def lazy(func, *resultclasses):
self.__dispatch[resultclass] = {}
for (k, v) in resultclass.__dict__.items():
setattr(self, k, self.__promise__(resultclass, k, v))
-
+
def __promise__(self, klass, funcname, func):
-
- """
- This function builds a wrapper around some magic method and
- registers that magic method for the given type and methodname.
- """
-
+ # Builds a wrapper around some magic method and registers that magic
+ # method for the given type and method name.
def __wrapper__(*args, **kw):
- """
- This wrapper function automatically triggers the evaluation of
- a lazy value. It then applies the given magic method of the
- result type.
- """
+ # Automatically triggers the evaluation of a lazy value and
+ # applies the given magic method of the result type.
res = self.__func(*self.__args, **self.__kw)
return self.__dispatch[type(res)][funcname](res, *args, **kw)
-
+
if not self.__dispatch.has_key(klass):
self.__dispatch[klass] = {}
self.__dispatch[klass][funcname] = func
return __wrapper__
-
+
def __wrapper__(*args, **kw):
- """
- This wrapper function just creates the proxy object that is returned
- instead of the actual value.
- """
+ # Creates the proxy object, instead of the actual value.
return __proxy__(args, kw)
return __wrapper__
-
-