Skip to content

Commit

Permalink
consolidate accept classes into the single Accept class
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Mar 2, 2024
1 parent 0a69ff1 commit 872755d
Show file tree
Hide file tree
Showing 8 changed files with 947 additions and 2,693 deletions.
34 changes: 29 additions & 5 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ Feature

- Add Request.remote_host, exposing REMOTE_HOST environment variable.

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

- Consolidation of ``Accept`` header handling into a single class.
See backward incompatibilities below for more information.
See https://github.com/Pylons/webob/pull/460

- ``webob.acceptparse.Accept``, methods ``best_match``, ``quality``, and
``__contains__`` are now convenience methods for most use-cases where
content-negotiation is needed versus using ``acceptable_offers`` directly.
See https://github.com/Pylons/webob/pull/460

Compatibility
~~~~~~~~~~~~~

Expand All @@ -27,6 +34,23 @@ Backwards Incompatibilities

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

- Remove ``AcceptValidHeader``, ``AcceptNoHeader`` and ``AcceptInvalidHeader``.
These classes are consolidated into ``Accept`` with a ``header_state``
attribute for users that need to know the exact state of the header.
See https://github.com/Pylons/webob/pull/460

- Remove previously-deprecated ``webob.acceptparse.MIMEAccept``.
See https://github.com/Pylons/webob/pull/460

- Remove previously-deprecated ``webob.acceptparse.Accept.__iter__``.
See https://github.com/Pylons/webob/pull/460

- ``webob.acceptparse.Accept`` methods, ``best_match``, ``quality``, and
``__contains__`` now require explicit media types with no wildcards or
server-side quality values. They will not match values with a quality of 0.
Their logic is consistent with ``acceptable_offers``.
See https://github.com/Pylons/webob/pull/460

Experimental Features
~~~~~~~~~~~~~~~~~~~~~

Expand Down
44 changes: 15 additions & 29 deletions docs/api/webob.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,85 +23,71 @@ a certain type:
The classes that may be returned by one of the functions above, and their
methods:

.. autoclass:: Accept
:members: parse

.. autoclass:: AcceptOffer
:members: __str__

.. autoclass:: AcceptValidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
accept_html, accepts_html, acceptable_offers, best_match, quality

.. autoclass:: AcceptNoHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
accept_html, accepts_html, acceptable_offers, best_match, quality
.. autoenum:: HeaderState

.. autoclass:: AcceptInvalidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
accept_html, accepts_html, acceptable_offers, best_match, quality
.. autoclass:: Accept
:members:
parse, header_value, parsed, header_state, __init__, __add__,
__bool__, __radd__, __repr__, __str__, __contains__,
accept_html, accepts_html, acceptable_offers, best_match, quality

.. autoclass:: AcceptCharset
:members: parse

.. autoclass:: AcceptCharsetValidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptCharsetNoHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptCharsetInvalidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptEncoding
:members: parse

.. autoclass:: AcceptEncodingValidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptEncodingNoHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptEncodingInvalidHeader
:members: parse, header_value, parsed, __init__, __add__, __bool__,
__contains__, __iter__, __radd__, __repr__, __str__,
__contains__, __iter__, __radd__, __repr__, __str__,
acceptable_offers, best_match, quality

.. autoclass:: AcceptLanguage
:members: parse

.. autoclass:: AcceptLanguageValidHeader
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
quality

.. autoclass:: AcceptLanguageNoHeader
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
quality

.. autoclass:: AcceptLanguageInvalidHeader
:members: header_value, parsed, __init__, __add__, __contains__, __iter__,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
__radd__, __str__, parse, basic_filtering, best_match, lookup,
quality

Deprecated:

.. autoclass:: MIMEAccept


Cache-Control
~~~~~~~~~~~~~
Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pkg_resources
import importlib.metadata
import sys
import os
import shlex

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"enum_tools.autoenum",
]

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

version = release = pkg_resources.get_distribution("webob").version
version = release = importlib.metadata.distribution("webob").version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ license_file = docs/license.txt
python_files = test_*.py
testpaths =
tests
addopts = -W always --cov --cov-report=term-missing
addopts = --cov --cov-report=term-missing
filterwarnings =
always
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"pytest-xdist",
]

docs_extras = ["Sphinx >= 1.7.5", "pylons-sphinx-themes"]
docs_extras = [
"Sphinx >= 1.7.5",
"pylons-sphinx-themes",
"enum-tools[sphinx]",
]

setup(
name="WebOb",
Expand Down
Loading

0 comments on commit 872755d

Please sign in to comment.