Permalink
Browse files

* ``Response.request`` and ``Response.environ`` attrs are undeprecate…

…d 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.
  • Loading branch information...
1 parent 13b848b commit 627593bbcd4ab52adc7ee569001cdda91c670d5d @mcdonc mcdonc committed Oct 6, 2011
Showing with 20 additions and 16 deletions.
  1. +10 −4 docs/news.txt
  2. +8 −6 tests/test_descriptors.py
  3. +2 −6 webob/response.py
View
@@ -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
---------
View
@@ -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
View
@@ -51,7 +51,6 @@
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')

0 comments on commit 627593b

Please sign in to comment.