diff options
| author | Chris McDonough <chrism@plope.com> | 2011-10-06 13:27:30 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-10-06 13:27:30 -0400 |
| commit | 627593bbcd4ab52adc7ee569001cdda91c670d5d (patch) | |
| tree | 2dec02e1a6ab3f4089191b9c18a50cd38d05f01a | |
| parent | 13b848b21df10e559452ec031f55c5537a4fa5e6 (diff) | |
| download | webob-627593bbcd4ab52adc7ee569001cdda91c670d5d.tar.gz | |
* ``Response.request`` and ``Response.environ`` attrs are undeprecated and no
longer raise exceptions when used. These can also be passed to the
Response constructor. This is to support codebases that pass them to the
constructor or assign them to a response instance. However, some behavior
differences from 1.1 exist. In particular, synchronization is no longer
done between environ and request attribute properties of Response; you may
pass either to the constructor (or both) or assign one or the other or
both, but they wont be managed specially and will remain the same over the
lifetime of the response just as you passed them. Default values for both
``request`` and ``environ`` on any given response are ``None`` now.
| -rw-r--r-- | docs/news.txt | 14 | ||||
| -rw-r--r-- | tests/test_descriptors.py | 14 | ||||
| -rw-r--r-- | webob/response.py | 8 |
3 files changed, 20 insertions, 16 deletions
diff --git a/docs/news.txt b/docs/news.txt index 2582660..d346602 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -15,10 +15,16 @@ master * ``Accept.best_matches()`` is gone. -* Fix deprecation error messages for ``response.request`` and - ``response.environ`` (they previously showed ``None`` as the attribute name - when displayed). - +* ``Response.request`` and ``Response.environ`` attrs are undeprecated and no + longer raise exceptions when used. These can also be passed to the + Response constructor. This is to support codebases that pass them to the + constructor or assign them to a response instance. However, some behavior + differences from 1.1 exist. In particular, synchronization is no longer + done between environ and request attribute properties of Response; you may + pass either to the constructor (or both) or assign one or the other or + both, but they wont be managed specially and will remain the same over the + lifetime of the response just as you passed them. Default values for both + ``request`` and ``environ`` on any given response are ``None`` now. 1.2a2 --------- diff --git a/tests/test_descriptors.py b/tests/test_descriptors.py index 2c83b3f..1c3691a 100644 --- a/tests/test_descriptors.py +++ b/tests/test_descriptors.py @@ -379,12 +379,14 @@ def test_date_header_fdel(): eq_(desc.fget(resp), None) def test_deprecated_property(): - from webob import Response - assert_raises(DeprecationWarning, Response, environ={}) - resp = Response() - assert_raises(DeprecationWarning, getattr, resp, 'environ') - assert_raises(DeprecationWarning, setattr, resp, 'environ', {}) - assert_raises(DeprecationWarning, delattr, resp, 'environ') + from webob.descriptors import deprecated_property + class Foo(object): + pass + Foo.attr = deprecated_property('attr', 'attr', 'whatever', '1.2') + foo = Foo() + assert_raises(DeprecationWarning, getattr, foo, 'attr') + assert_raises(DeprecationWarning, setattr, foo, 'attr', {}) + assert_raises(DeprecationWarning, delattr, foo, 'attr') def test_parse_etag_response(): from webob.descriptors import parse_etag_response diff --git a/webob/response.py b/webob/response.py index 3c1163a..853985d 100644 --- a/webob/response.py +++ b/webob/response.py @@ -51,7 +51,6 @@ from webob.descriptors import ( serialize_content_range, serialize_etag_response, serialize_int, - deprecated_property, ) from webob.headers import ResponseHeaders @@ -74,6 +73,8 @@ class Response(object): default_charset = 'UTF-8' # TODO: deprecate unicode_errors = 'strict' # TODO: deprecate (why would response body have errors?) default_conditional_response = False + request = None + environ = None # # __init__, from_file, copy @@ -1177,8 +1178,3 @@ def _error_unicode_in_app_iter(app_iter, body): raise TypeError( 'An item of the app_iter (%s) was text, causing a ' 'text body: %r' % (app_iter_repr, body)) - - -# TODO: remove in 1.4 -Response.request = deprecated_property('request', 'request', 'Response.request will be removed completely in 1.4', '1.2') -Response.environ = deprecated_property('environ', 'environ', 'Response.environ will be removed completely in 1.4', '1.2') |
