Skip to content

Commit 36171cb

Browse files
committed
consolidate accept classes into the single Accept class
1 parent 0a69ff1 commit 36171cb

File tree

8 files changed

+968
-2706
lines changed

8 files changed

+968
-2706
lines changed

CHANGES.txt

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ Feature
1010

1111
- Add Request.remote_host, exposing REMOTE_HOST environment variable.
1212

13-
- Added ``acceptparse.Accept.parse_offer`` to codify what types of offers
14-
are compatible with ``acceptparse.AcceptValidHeader.acceptable_offers``,
15-
``acceptparse.AcceptMissingHeader.acceptable_offers``, and
16-
``acceptparse.AcceptInvalidHeader.acceptable_offers``. This API also
17-
normalizes the offer with lowercased type/subtype and parameter names.
13+
- Added ``webob.acceptparse.Accept.parse_offer`` to codify what types of offers
14+
are compatible with ``webob.acceptparse.Accept.acceptable_offers``. This API
15+
also normalizes the offer with lowercased type/subtype and parameter names.
1816
See https://github.com/Pylons/webob/pull/376 and
1917
https://github.com/Pylons/webob/pull/379
2018

19+
- Consolidation of ``Accept`` header handling into a single class.
20+
See backward incompatibilities below for more information.
21+
See https://github.com/Pylons/webob/pull/460
22+
23+
- ``webob.acceptparse.Accept``, methods ``best_match``, ``quality``, and
24+
``__contains__`` are undeprecated and their logic is made consistent with
25+
``acceptable_offers``. See backward incompatibilities below.
26+
See https://github.com/Pylons/webob/pull/460
27+
2128
Compatibility
2229
~~~~~~~~~~~~~
2330

@@ -27,6 +34,28 @@ Backwards Incompatibilities
2734

2835
- Drop support for Python 2.7, 3.4, 3.5, 3.6, and 3.7.
2936

37+
- Remove ``AcceptValidHeader``, ``AcceptNoHeader`` and ``AcceptInvalidHeader``.
38+
These classes are consolidated into ``Accept`` with a ``header_state``
39+
attribute for users that need to know the exact state of the header.
40+
See https://github.com/Pylons/webob/pull/460
41+
42+
- Remove previously-deprecated ``webob.acceptparse.MIMEAccept``.
43+
See https://github.com/Pylons/webob/pull/460
44+
45+
- Remove previously-deprecated ``webob.acceptparse.Accept.__iter__``.
46+
See https://github.com/Pylons/webob/pull/460
47+
48+
- ``webob.acceptparse.Accept`` methods, ``best_match``, ``quality``, and
49+
``__contains__`` are now thin wrappers around ``acceptable_offers`` which
50+
modifies their behavior slightly:
51+
52+
- Offers containing wildcards are no longer allowed.
53+
- A tuple can no longer be an offer containing server-side quality values.
54+
- An offer will only match a wildcard clause in the header, such as ``*/*``
55+
or ``text/*`` if it does not match something more specific.
56+
57+
See https://github.com/Pylons/webob/pull/460
58+
3059
Experimental Features
3160
~~~~~~~~~~~~~~~~~~~~~
3261

docs/api/webob.txt

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,85 +23,71 @@ a certain type:
2323
The classes that may be returned by one of the functions above, and their
2424
methods:
2525

26-
.. autoclass:: Accept
27-
:members: parse
28-
2926
.. autoclass:: AcceptOffer
3027
:members: __str__
3128

32-
.. autoclass:: AcceptValidHeader
33-
:members: parse, header_value, parsed, __init__, __add__, __bool__,
34-
__contains__, __iter__, __radd__, __repr__, __str__,
35-
accept_html, accepts_html, acceptable_offers, best_match, quality
36-
37-
.. autoclass:: AcceptNoHeader
38-
:members: parse, header_value, parsed, __init__, __add__, __bool__,
39-
__contains__, __iter__, __radd__, __repr__, __str__,
40-
accept_html, accepts_html, acceptable_offers, best_match, quality
29+
.. autoenum:: HeaderState
4130

42-
.. autoclass:: AcceptInvalidHeader
43-
:members: parse, header_value, parsed, __init__, __add__, __bool__,
44-
__contains__, __iter__, __radd__, __repr__, __str__,
45-
accept_html, accepts_html, acceptable_offers, best_match, quality
31+
.. autoclass:: Accept
32+
:members:
33+
parse, header_value, parsed, header_state, __init__, __add__,
34+
__bool__, __radd__, __repr__, __str__, __contains__,
35+
accept_html, accepts_html, acceptable_offers, best_match, quality
4636

4737
.. autoclass:: AcceptCharset
4838
:members: parse
4939

5040
.. autoclass:: AcceptCharsetValidHeader
5141
:members: parse, header_value, parsed, __init__, __add__, __bool__,
52-
__contains__, __iter__, __radd__, __repr__, __str__,
42+
__contains__, __iter__, __radd__, __repr__, __str__,
5343
acceptable_offers, best_match, quality
5444

5545
.. autoclass:: AcceptCharsetNoHeader
5646
:members: parse, header_value, parsed, __init__, __add__, __bool__,
57-
__contains__, __iter__, __radd__, __repr__, __str__,
47+
__contains__, __iter__, __radd__, __repr__, __str__,
5848
acceptable_offers, best_match, quality
5949

6050
.. autoclass:: AcceptCharsetInvalidHeader
6151
:members: parse, header_value, parsed, __init__, __add__, __bool__,
62-
__contains__, __iter__, __radd__, __repr__, __str__,
52+
__contains__, __iter__, __radd__, __repr__, __str__,
6353
acceptable_offers, best_match, quality
6454

6555
.. autoclass:: AcceptEncoding
6656
:members: parse
6757

6858
.. autoclass:: AcceptEncodingValidHeader
6959
:members: parse, header_value, parsed, __init__, __add__, __bool__,
70-
__contains__, __iter__, __radd__, __repr__, __str__,
60+
__contains__, __iter__, __radd__, __repr__, __str__,
7161
acceptable_offers, best_match, quality
7262

7363
.. autoclass:: AcceptEncodingNoHeader
7464
:members: parse, header_value, parsed, __init__, __add__, __bool__,
75-
__contains__, __iter__, __radd__, __repr__, __str__,
65+
__contains__, __iter__, __radd__, __repr__, __str__,
7666
acceptable_offers, best_match, quality
7767

7868
.. autoclass:: AcceptEncodingInvalidHeader
7969
:members: parse, header_value, parsed, __init__, __add__, __bool__,
80-
__contains__, __iter__, __radd__, __repr__, __str__,
70+
__contains__, __iter__, __radd__, __repr__, __str__,
8171
acceptable_offers, best_match, quality
8272

8373
.. autoclass:: AcceptLanguage
8474
:members: parse
8575

8676
.. autoclass:: AcceptLanguageValidHeader
8777
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
88-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
78+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
8979
quality
9080

9181
.. autoclass:: AcceptLanguageNoHeader
9282
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
93-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
83+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
9484
quality
9585

9686
.. autoclass:: AcceptLanguageInvalidHeader
9787
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
98-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
88+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
9989
quality
10090

101-
Deprecated:
102-
103-
.. autoclass:: MIMEAccept
104-
10591

10692
Cache-Control
10793
~~~~~~~~~~~~~

docs/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import pkg_resources
1+
import importlib.metadata
22
import sys
33
import os
44
import shlex
55

66
extensions = [
77
"sphinx.ext.autodoc",
88
"sphinx.ext.intersphinx",
9+
"enum_tools.autoenum",
910
]
1011

1112
# Add any paths that contain templates here, relative to this directory.
@@ -27,7 +28,7 @@
2728
copyright = "2018, Ian Bicking, Pylons Project and contributors"
2829
author = "Ian Bicking, Pylons Project, and contributors"
2930

30-
version = release = pkg_resources.get_distribution("webob").version
31+
version = release = importlib.metadata.distribution("webob").version
3132

3233
# The language for content autogenerated by Sphinx. Refer to documentation
3334
# for a list of supported languages.

setup.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ license_file = docs/license.txt
88
python_files = test_*.py
99
testpaths =
1010
tests
11-
addopts = -W always --cov --cov-report=term-missing
11+
addopts = --cov --cov-report=term-missing
12+
filterwarnings =
13+
always

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"pytest-xdist",
1919
]
2020

21-
docs_extras = ["Sphinx >= 1.7.5", "pylons-sphinx-themes"]
21+
docs_extras = [
22+
"Sphinx >= 1.7.5",
23+
"pylons-sphinx-themes",
24+
"enum-tools[sphinx]",
25+
]
2226

2327
setup(
2428
name="WebOb",

0 commit comments

Comments
 (0)