What’s New in WebOb 1.8
Feature
- Request.POST now supports any requests with the appropriate Content-Type. Allowing any HTTP method to access form encoded content, including DELETE, PUT, and others. See https://github.com/Pylons/webob/pull/352
Compatibility
WebOb is no longer officially supported on Python 3.3 which was EOL’ed on 2017-09-29.
Please pin to WebOb~=1.7 which was tested against Python 3.3, and upgrade your Python version.
Backwards Incompatibilities
Many changes have been made to the way WebOb does Accept handling, not just for the
Accept
header itself, but also forAccept-Charset
,Accept-Encoding
andAccept-Language
. This was a Google Summer of Code project completed by Whiteroses (https://github.com/whiteroses). Many thanks to Google for running GSoC, the Python Software Foundation for organising and a huge thanks to Ira for completing the work. See https://github.com/Pylons/webob/pull/338 and https://github.com/Pylons/webob/pull/335.If you were previously using the
Accept
class or theMIMEAccept
class directly, please take a look at the documentation for create_accept_header(), create_accept_charset_header(), create_accept_encoding_header() and create_accept_language_header().These functions will accept a header value and create the appropriate object.
The API documentation for Accept* provides more information on the available API.
When calling a
@wsgify
decorated function, the default arguments passed to@wsgify
are now used when called with the request, and not as a start_responsedef hello(req, name):
return "Hello, %s!" % name
app = wsgify(hello, args=("Fred",))
req = Request.blank('/')
resp = req.get_response(app) # => "Hello, Fred"
resp2 = app(req) # => "Hello, Fred"
Previously the
resp2
line would have failed with aTypeError
. With this change there is no way to override the default arguments with no arguments. See https://github.com/Pylons/webob/pull/203When setting
app_iter
on aResponse
object thecontent_md5
header is no longer cleared. This behaviour is odd and disallows setting thecontent_md5
and then returning an iterator for chunked content encoded responses. See https://github.com/Pylons/webob/issues/86
Experimental Features
These features are experimental and may change at any point in the future. The main page provides a list of Experimental API supported by WebOb.
- The cookie APIs now have the ability to set the SameSite attribute on a cookie in both webob.cookies.make_cookie() and webob.cookies.CookieProfile. See https://github.com/Pylons/webob/pull/255
Bugfix
- Request.host_url, Request.host_port, Request.domain correctly parse IPv6 Host headers as provided by a browser. See https://github.com/Pylons/webob/pull/332
- Request.authorization would raise ValueError for unusual or malformed header values. Now it simply returns an empty value. See https://github.com/Pylons/webob/issues/231
- Allow unnamed fields in form data to be properly transcoded when calling
request.decode
with an alternate encoding. See https://github.com/Pylons/webob/pull/309 - Response.__init__ would discard
app_iter
when aResponse
had no body, this would cause issues whenapp_iter
was an object that was tied to the life-cycle of a web application and had to be properly closed.app_iter
is more advanced API forResponse
and thus even if it contains a body and is thus against the HTTP RFC’s, we should let the users shoot themselves in the foot by returning a body. See https://github.com/Pylons/webob/issues/305