Commit graph

184 commits

Author SHA1 Message Date
Dave Shawley
198e73b6ef
Implement form encoding of sequence values.
This is off by default to match the `doseq` parameter of
urllib.parse.urlencode.
2021-10-14 07:54:32 -04:00
Dave Shawley
1fe22df719
Gracefully handle transcoder encoding failures.
Since the form encoder refuses to handle nested sequences, the content
mixin explicitly handles this case instead of letting the unhandled
exception bubble up.
2021-10-14 07:12:08 -04:00
Dave Shawley
2df3aade3c
Improve documentation for FormUrlEncodedTranscoder. 2021-10-14 07:12:08 -04:00
Dave Shawley
ee66c5cadb
Optimize the URL encoding inner loop.
I rearranged the _encode method branching a bit.  This resulted in a
little more than a 12% gain.  Still slower than JSON or msgpack but it's
in python instead of C.
2021-10-14 07:12:08 -04:00
Dave Shawley
25ec09972c
Add uuid support to FormUrlEncodedTranscoder. 2021-10-14 07:12:07 -04:00
Dave Shawley
4fd3864c04
Rejected serialization of non-pair sequences.
This required a bit of change in _encode to detect non-pair sequences
that are also not strings or byte strings.
2021-10-14 07:12:07 -04:00
Dave Shawley
e99d41a8b4
Refuse to serialize None, True, False.
If someone explicitly removes the literal mappings, then refuse to
serialize None, True, and False instead of guessing.  Note that I
explicitly included True and False in the branch logic since bool is a
subclass of int but str(True) != str(int(True)) :/
2021-10-14 07:12:07 -04:00
Dave Shawley
3aa08b7435
Implement serialization of primitive values.
This isn't covered by the serialization specification but is accounted
for in the deserialization side.
2021-10-14 07:12:07 -04:00
Dave Shawley
716bff0d7f
Add application/x-www-formurlencoded transcoder.
I ended up not using urllib.parse functions since they do not implement
the specification.  The only difference is that the specification
requires that "~" is encoded.

NB - this commit is incomplete since it does not handle calling the
transcoder on simple objects.  mypy will quite correctly fail.
2021-10-14 07:12:01 -04:00
Kevin Vance
4dbc74076d
Merge pull request #41 from dave-shawley/add-typing
Add type annotations
2021-10-05 10:22:49 -04:00
Dave Shawley
2047fe8d16
Increase test coverage to 100% 2021-10-04 07:30:42 -04:00
Dave Shawley
9ff5ca3781
Fail gracefully when transcoder is missing.
If there is no transcoder for the default content type, sending a
response would fail with a "500 Internal Server Error" due to an
*unhandled* KeyError.  This commit catches the KeyError and produces
an explicit "500 Internal Server Error" with an appropriate error
message being logged.
2021-10-03 15:52:48 -04:00
Dave Shawley
d605acb5b7
Deprecate not configuring a default content type. 2021-10-03 15:52:48 -04:00
Dave Shawley
4dd46eda5b
Return 406 Not Acceptable appropriately.
If there is no default content type and nothing matches in the Accept
header, previous versions would fail with an Internal Server Error
because of an unhandled exception.  Instead we should be returning
a "406 Not Acceptable".
2021-10-03 15:52:47 -04:00
Dave Shawley
25ba46e960
Fix build badge in README. 2021-10-03 15:52:47 -04:00
Dave Shawley
36244966e4
Subtly prefer add_transcoder in docs. 2021-10-03 15:52:47 -04:00
Dave Shawley
4a0ca5e390
Documentation updates for typing.
The changes to `api.rst` are particularly important since that is where
I describe the externally available type annotations.
2021-10-03 15:52:47 -04:00
Dave Shawley
acc0a1db14
Add type annotations.
The next commit is a pile of documentation updates that I didn't want
cluttering up this commit.
2021-10-03 15:52:43 -04:00
Andrew Rabert
a528661c98
Merge pull request #40 from dave-shawley/code-formatting
Reformat using yapf.
2021-09-19 13:09:25 -04:00
Dave Shawley
de43997df5
Reformat using yapf.
https://github.com/sprockets/sprockets.mixins.mediatype/issues/35
2021-09-19 09:58:08 -04:00
dave-shawley
211d6cb97c
Merge pull request #39 from dave-shawley/fix-nspkgs
Fix namespace packaging.
2021-09-19 09:56:58 -04:00
Dave Shawley
9d3e53b060
Fix namespace packaging.
Just oops.... I also updated tox.ini so that it checks all-the-things
and works again.
2021-09-19 09:54:47 -04:00
dave-shawley
d5094e00f5
Merge pull request #38 from dave-shawley/rtd-build
Move readthedocs configuration into the repository.
2021-09-17 08:12:57 -04:00
Dave Shawley
cc08f7b2fd
Remove nose configuration. 2021-09-17 08:10:35 -04:00
Dave Shawley
d5d2259ffd
Build the documentation in CI.
Even though we aren't uploading it, this *should* make sure that the
readthedocs build works.
2021-09-17 08:09:15 -04:00
Dave Shawley
026fd87e82
Add readthedocs configuration file.
The configuration in the RTD project is broken since I moved
dependencies into setup.cfg.  I decided to simply move it into the
repository as a configuration file and call it a day.

https://docs.readthedocs.io/en/stable/config-file/v2.html
2021-09-17 07:46:48 -04:00
Andrew Rabert
f186c6bf1a
Merge pull request #31 from dave-shawley/metadata
Clean up package structure
2021-09-16 10:58:42 -04:00
Dave Shawley
7472c399fb
Lint ignore some of the weird stuff in __init__.
Adjusted flake8 & coverage ignores for the namespace package cruft and
the import guards in the __init__ files.
2021-09-16 09:54:16 -04:00
Dave Shawley
e26a94778b
Using sphinx-rtd-theme locally as well. 2021-09-16 09:54:15 -04:00
Dave Shawley
118c610d3c
Bump copyright date in documentation. 2021-09-16 09:54:15 -04:00
Dave Shawley
61ac443c17
Remove travis-ci control file. 2021-09-16 09:54:15 -04:00
Dave Shawley
775991eb9f
Move requirements into setup.cfg. 2021-09-16 09:53:48 -04:00
Dave Shawley
e9e5f25925
Move metadata from setup.py into setup.cfg. 2021-09-16 09:49:42 -04:00
dave-shawley
10825d29fa
Merge pull request #37 from dave-shawley/contributing-docs
Make contribution guidelines more visible
2021-09-16 09:49:22 -04:00
Dave Shawley
13d90516ab
Stitch CONTRIBUTING back into the doc set. 2021-09-16 09:47:30 -04:00
Dave Shawley
f725e16aee
Increase visibility of docs/contributing.rst. 2021-09-16 09:47:26 -04:00
Dave Shawley
d1a4511955
Remove codecov token from GitHub action.
It wasn't working with the token and the docs indicate that it is not
necessary for GitHub actions so lets see what happens.
2021-09-14 07:53:11 -04:00
Ryan Mclean
5712c36217
Merge pull request #30 from dave-shawley/updates
Update build tools and switch to GitHub actions
2021-09-13 07:35:34 -04:00
dave-shawley
85686397d6
Update testing.yml
to be squishy squashed
2021-09-13 06:52:56 -04:00
dave-shawley
9df7604012
Update testing.yml
will be squashed away in the future
2021-09-13 06:50:04 -04:00
Dave Shawley
9993a81e51
Add first draft of Github CI pipeline. 2021-09-13 06:45:01 -04:00
Dave Shawley
77ecc36026
Enforce 95% code coverage, 2021-09-13 06:28:39 -04:00
Dave Shawley
665eb71436
Seperate linting requirements.
This will ease implementing Github actions.
2021-09-12 18:34:16 -04:00
Dave Shawley
c6551e8024
Stop using the tornado reloader in tests.
This causes some interesting warnings.
2021-09-12 18:34:16 -04:00
Dave Shawley
66f3bfbca3
Bump LICENSE date. 2021-09-12 18:34:15 -04:00
Dave Shawley
3a6b98eb1c
Update development toolchain. 2021-09-12 18:34:15 -04:00
Dave Shawley
9ab953ed23
Use extlinks for changelog. 2021-09-12 18:34:08 -04:00
Dave Shawley
f6f84bdd2c 3.0.4: Reject invalid Content-Type headers. 2020-11-02 09:21:08 -05:00
Ryan Mclean
457dc178f3
Merge pull request #29 from dave-shawley/handle-bad-content-type
Handle Invalid Content-Type headers
2020-10-29 17:17:22 -04:00
Dave Shawley
21c6cb73fe Invalid content-type --> 400 Bad Request.
ietfparse raises a `ValueError` from `parse_content_type` which was
uncaught and resulted in an internal server error.
2020-10-29 13:50:33 -04:00