summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt7
-rw-r--r--TODO.txt3
-rw-r--r--docs/api.rst1
-rw-r--r--docs/api/decorator.rst9
-rw-r--r--pyramid/decorator.py28
-rw-r--r--pyramid/testing.py2
6 files changed, 44 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 47f51575c..94c331cef 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -160,6 +160,9 @@ Features
- ``request.context`` of environment request during ``bootstrap`` is now the
root object if a context isn't already set on a provided request.
+- The ``pyramid.decorator.reify`` function is now an API, and was added to
+ the API documentation.
+
Deprecations
------------
@@ -250,7 +253,9 @@ Documentation
-------------
- Added an "Upgrading Pyramid" chapter to the narrative documentation. It
- describes how to cope with deprecations and removals of Pyramid APIs.
+ describes how to cope with deprecations and removals of Pyramid APIs and
+ how to show Pyramid-generated deprecation warnings while running tests and
+ while running a server.
Dependencies
------------
diff --git a/TODO.txt b/TODO.txt
index a13433f54..202d1afbb 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -143,7 +143,8 @@ Future
original dict (after ``__getattr__`` deprecation period, it was deprecated
in 1.2).
-- 1.5: Remove ``pyramid.requests.DeprecatedRequestMethodsMixin``.
+- 1.5: Remove ``pyramid.requests.DeprecatedRequestMethodsMixin`` and code in
+ renderers module that looks for _response_content_type, et. al.
- 1.5: Maybe? deprecate set_request_property in favor of pointing people at
add_request_method, schedule removal for 1.8?
diff --git a/docs/api.rst b/docs/api.rst
index e33fd6a74..9e540b49b 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -12,6 +12,7 @@ documentation is organized alphabetically by module name.
api/authentication
api/compat
api/config
+ api/decorator
api/events
api/exceptions
api/httpexceptions
diff --git a/docs/api/decorator.rst b/docs/api/decorator.rst
new file mode 100644
index 000000000..35d9131df
--- /dev/null
+++ b/docs/api/decorator.rst
@@ -0,0 +1,9 @@
+.. _decorator_module:
+
+:mod:`pyramid.decorator`
+--------------------------
+
+.. automodule:: pyramid.decorator
+
+.. autofunction:: reify
+
diff --git a/pyramid/decorator.py b/pyramid/decorator.py
index 98d7b36b5..82d2b1280 100644
--- a/pyramid/decorator.py
+++ b/pyramid/decorator.py
@@ -1,9 +1,31 @@
class reify(object):
+ """ Use as a class method decorator. It operates almost exactly like the
+ Python ``@property`` decorator, but it puts the result of the method it
+ decorates into the instance dict after the first call, effectively
+ replacing the function it decorates with an instance variable. It is, in
+ Python parlance, a non-data descriptor. An example:
- """ Put the result of a method which uses this (non-data)
- descriptor decorator in the instance dict after the first call,
- effectively replacing the decorator with an instance variable."""
+ .. code-block:: python
+ class Foo(object):
+ @reify
+ def jammy(self):
+ print 'jammy called'
+ return 1
+
+ And usage of Foo:
+
+ .. code-block:: text
+
+ >>> f = Foo()
+ >>> v = f.jammy
+ 'jammy called'
+ >>> print v
+ 1
+ >>> f.jammy
+ 1
+ >>> # jammy func not called the second time; it replaced itself with 1
+ """
def __init__(self, wrapped):
self.wrapped = wrapped
try:
diff --git a/pyramid/testing.py b/pyramid/testing.py
index 750effb83..e091bac4f 100644
--- a/pyramid/testing.py
+++ b/pyramid/testing.py
@@ -293,7 +293,7 @@ class DummyRequest(DeprecatedRequestMethodsMixin, URLMethodsMixin,
request. For example, by default, the DummyRequest ``GET`` and ``POST``
attributes are of type ``dict``, unlike a normal Request's GET and POST,
which are of type ``MultiDict``. If your code uses the features of
- MultiDict, you should either use a"real" :class:`pyramid.request.Request`
+ MultiDict, you should either use a real :class:`pyramid.request.Request`
or adapt your DummyRequest by replacing the attributes with ``MultiDict``
instances.