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 Feb 27, 2024
1 parent 0a69ff1 commit cbc0f3b
Show file tree
Hide file tree
Showing 8 changed files with 931 additions and 2,734 deletions.
28 changes: 28 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Feature
See https://github.com/Pylons/webob/pull/376 and
https://github.com/Pylons/webob/pull/379

- Significant consolidation of ``Accept`` header handling into a single
``AcceptHeader`` class.
See https://github.com/Pylons/webob/pull/460

- ``webob.acceptparse.Accept.best_match`` is now a convenience method for
most use-cases where content-negotiation is needed server-side instead of
using ``acceptable_offers`` directly.
See https://github.com/Pylons/webob/pull/460

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

Expand All @@ -27,6 +36,25 @@ 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 ``AcceptHeader`` with a ``header_state``
attribute for users that need to know the 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.__contains__``,
``webob.acceptparse.Accept.__iter__``, and
``webob.acceptparse.Accept.quality``.
See https://github.com/Pylons/webob/pull/460

- Change behavior of ``webob.acceptparse.Accept.best_match`` to no longer
allow offers that are not mimetypes and to no longer allow offers with
server-side quality values. Logic is now normalized to use
``webob.acceptparse.Accept.acceptable_offers``.
See https://github.com/Pylons/webob/pull/460

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

Expand Down
43 changes: 14 additions & 29 deletions docs/api/webob.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,85 +23,70 @@ 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__,
accept_html, accepts_html, acceptable_offers, best_match

.. 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 cbc0f3b

Please sign in to comment.