diff options
| author | Michael Merickel <michael@merickel.org> | 2012-01-11 02:04:22 -0600 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2012-01-11 02:05:06 -0600 |
| commit | 1b113f772b48862c99e8269ca59365bc2acff85c (patch) | |
| tree | c9a5d38dbefcf0414395384bb128c141fda04e60 | |
| parent | cf3a11e990adda800e284effb006f1c28335da4d (diff) | |
| download | pyramid-1b113f772b48862c99e8269ca59365bc2acff85c.tar.gz pyramid-1b113f772b48862c99e8269ca59365bc2acff85c.tar.bz2 pyramid-1b113f772b48862c99e8269ca59365bc2acff85c.zip | |
Renamed the func to callable in the docs.
| -rw-r--r-- | docs/api/request.rst | 14 | ||||
| -rw-r--r-- | pyramid/util.py | 29 |
2 files changed, 22 insertions, 21 deletions
diff --git a/docs/api/request.rst b/docs/api/request.rst index 9596e5621..1ab84e230 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -208,9 +208,7 @@ body associated with this request, this property will raise an exception. See also :ref:`request_json_body`. - .. method:: set_property(func, name=None, reify=False) - - .. versionadded:: 1.3 + .. method:: set_property(callable, name=None, reify=False) Add a callable or a property descriptor to the request instance. @@ -225,15 +223,15 @@ cached. Thus the value of the property is only computed once for the lifetime of the object. - ``func`` can either be a callable that accepts the request as + ``callable`` can either be a callable that accepts the request as its single positional parameter, or it can be a property descriptor. - If the ``func`` is a property descriptor a ``ValueError`` will - be raised if ``name`` is ``None`` or ``reify`` is ``True``. + If the ``callable`` is a property descriptor a ``ValueError`` + will be raised if ``name`` is ``None`` or ``reify`` is ``True``. If ``name`` is None, the name of the property will be computed - from the name of the ``func``. + from the name of the ``callable``. .. code-block:: python :linenos: @@ -259,6 +257,8 @@ without having to subclass it, which can be useful for extension authors. + .. versionadded:: 1.3 + .. note:: For information about the API of a :term:`multidict` structure (such as diff --git a/pyramid/util.py b/pyramid/util.py index 852689c4d..cca1872b7 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -20,7 +20,7 @@ class InstancePropertyMixin(object): on the class itself. """ - def set_property(self, func, name=None, reify=False): + def set_property(self, callable, name=None, reify=False): """ Add a callable or a property descriptor to the instance. Properties, unlike attributes, are lazily evaluated by executing @@ -34,17 +34,18 @@ class InstancePropertyMixin(object): cached. Thus the value of the property is only computed once for the lifetime of the object. - ``func`` can either be a callable that accepts the instance as + ``callable`` can either be a callable that accepts the instance + as its single positional parameter, or it can be a property descriptor. - If the ``func`` is a property descriptor, the ``name`` parameter - must be supplied or a ``ValueError`` will be raised. Also note - that a property descriptor cannot be reified, so ``reify`` must - be ``False``. + If the ``callable`` is a property descriptor, the ``name`` + parameter must be supplied or a ``ValueError`` will be raised. + Also note that a property descriptor cannot be reified, so + ``reify`` must be ``False``. If ``name`` is None, the name of the property will be computed - from the name of the ``func``. + from the name of the ``callable``. .. code-block:: python :linenos: @@ -73,20 +74,20 @@ class InstancePropertyMixin(object): 1 """ - is_property = isinstance(func, property) + is_property = isinstance(callable, property) if is_property: - fn = func + fn = callable if name is None: raise ValueError('must specify "name" for a property') if reify: raise ValueError('cannot reify a property') elif name is not None: - fn = lambda this: func(this) + fn = lambda this: callable(this) fn.__name__ = name - fn.__doc__ = func.__doc__ + fn.__doc__ = callable.__doc__ else: - name = func.__name__ - fn = func + name = callable.__name__ + fn = callable if reify: import pyramid.decorator fn = pyramid.decorator.reify(fn) @@ -234,7 +235,7 @@ def object_description(object): return text_('method %s of class %s.%s' % (object.__name__, modulename, oself.__class__.__name__)) - + if inspect.isclass(object): dottedname = '%s.%s' % (modulename, object.__name__) return text_('class %s' % dottedname) |
