Skip to content

Commit cbc0f3b

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

File tree

8 files changed

+931
-2734
lines changed

8 files changed

+931
-2734
lines changed

CHANGES.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ Feature
1818
See https://github.com/Pylons/webob/pull/376 and
1919
https://github.com/Pylons/webob/pull/379
2020

21+
- Significant consolidation of ``Accept`` header handling into a single
22+
``AcceptHeader`` class.
23+
See https://github.com/Pylons/webob/pull/460
24+
25+
- ``webob.acceptparse.Accept.best_match`` is now a convenience method for
26+
most use-cases where content-negotiation is needed server-side instead of
27+
using ``acceptable_offers`` directly.
28+
See https://github.com/Pylons/webob/pull/460
29+
2130
Compatibility
2231
~~~~~~~~~~~~~
2332

@@ -27,6 +36,25 @@ Backwards Incompatibilities
2736

2837
- Drop support for Python 2.7, 3.4, 3.5, 3.6, and 3.7.
2938

39+
- Remove ``AcceptValidHeader``, ``AcceptNoHeader`` and ``AcceptInvalidHeader``.
40+
These classes are consolidated into ``AcceptHeader`` with a ``header_state``
41+
attribute for users that need to know the state of the header.
42+
See https://github.com/Pylons/webob/pull/460
43+
44+
- Remove previously-deprecated ``webob.acceptparse.MIMEAccept``.
45+
See https://github.com/Pylons/webob/pull/460
46+
47+
- Remove previously-deprecated ``webob.acceptparse.Accept.__contains__``,
48+
``webob.acceptparse.Accept.__iter__``, and
49+
``webob.acceptparse.Accept.quality``.
50+
See https://github.com/Pylons/webob/pull/460
51+
52+
- Change behavior of ``webob.acceptparse.Accept.best_match`` to no longer
53+
allow offers that are not mimetypes and to no longer allow offers with
54+
server-side quality values. Logic is now normalized to use
55+
``webob.acceptparse.Accept.acceptable_offers``.
56+
See https://github.com/Pylons/webob/pull/460
57+
3058
Experimental Features
3159
~~~~~~~~~~~~~~~~~~~~~
3260

docs/api/webob.txt

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,85 +23,70 @@ 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: parse, header_value, parsed, header_state, __init__, __add__,
33+
__bool__, __radd__, __repr__, __str__,
34+
accept_html, accepts_html, acceptable_offers, best_match
4635

4736
.. autoclass:: AcceptCharset
4837
:members: parse
4938

5039
.. autoclass:: AcceptCharsetValidHeader
5140
:members: parse, header_value, parsed, __init__, __add__, __bool__,
52-
__contains__, __iter__, __radd__, __repr__, __str__,
41+
__contains__, __iter__, __radd__, __repr__, __str__,
5342
acceptable_offers, best_match, quality
5443

5544
.. autoclass:: AcceptCharsetNoHeader
5645
:members: parse, header_value, parsed, __init__, __add__, __bool__,
57-
__contains__, __iter__, __radd__, __repr__, __str__,
46+
__contains__, __iter__, __radd__, __repr__, __str__,
5847
acceptable_offers, best_match, quality
5948

6049
.. autoclass:: AcceptCharsetInvalidHeader
6150
:members: parse, header_value, parsed, __init__, __add__, __bool__,
62-
__contains__, __iter__, __radd__, __repr__, __str__,
51+
__contains__, __iter__, __radd__, __repr__, __str__,
6352
acceptable_offers, best_match, quality
6453

6554
.. autoclass:: AcceptEncoding
6655
:members: parse
6756

6857
.. autoclass:: AcceptEncodingValidHeader
6958
:members: parse, header_value, parsed, __init__, __add__, __bool__,
70-
__contains__, __iter__, __radd__, __repr__, __str__,
59+
__contains__, __iter__, __radd__, __repr__, __str__,
7160
acceptable_offers, best_match, quality
7261

7362
.. autoclass:: AcceptEncodingNoHeader
7463
:members: parse, header_value, parsed, __init__, __add__, __bool__,
75-
__contains__, __iter__, __radd__, __repr__, __str__,
64+
__contains__, __iter__, __radd__, __repr__, __str__,
7665
acceptable_offers, best_match, quality
7766

7867
.. autoclass:: AcceptEncodingInvalidHeader
7968
:members: parse, header_value, parsed, __init__, __add__, __bool__,
80-
__contains__, __iter__, __radd__, __repr__, __str__,
69+
__contains__, __iter__, __radd__, __repr__, __str__,
8170
acceptable_offers, best_match, quality
8271

8372
.. autoclass:: AcceptLanguage
8473
:members: parse
8574

8675
.. autoclass:: AcceptLanguageValidHeader
8776
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
88-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
77+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
8978
quality
9079

9180
.. autoclass:: AcceptLanguageNoHeader
9281
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
93-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
82+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
9483
quality
9584

9685
.. autoclass:: AcceptLanguageInvalidHeader
9786
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
98-
__radd__, __str__, parse, basic_filtering, best_match, lookup,
87+
__radd__, __str__, parse, basic_filtering, best_match, lookup,
9988
quality
10089

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

10691
Cache-Control
10792
~~~~~~~~~~~~~

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)