Skip to content

Commit

Permalink
Merge pull request #62 from sloria/marshmallow
Browse files Browse the repository at this point in the history
Use marshmallow to define args and do validation
  • Loading branch information
sloria committed Sep 27, 2015
2 parents 5001d30 + 3c100a0 commit 5b3277b
Show file tree
Hide file tree
Showing 109 changed files with 29,074 additions and 2,909 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ python:
- "pypy"

install:
- pip install -U -r dev-requirements.txt
- pip install -U .
- pip install -U -r dev-requirements.txt

before_script: flake8 webargs

script: py.test


9 changes: 8 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
=======
Credits
Authors
=======

Lead
----

* Steven Loria <sloria1@gmail.com>

Contributors (chronological)
----------------------------

* @venuatu <https://github.com/venuatu>
* Javier Santacruz @jvrsantacruz <javier.santacruz.lc@gmail.com>
* Josh Carp <https://github.com/jmcarp>
Expand Down
57 changes: 57 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
Changelog
---------

0.16.0 (unreleased)
*******************

The major change in this release is that webargs now depends on `marshmallow <https://marshmallow.readthedocs.org/en/latest/>`_ for defining arguments and for validation.

Your code will need to be updated to use ``Fields`` rather than ``Args``.

.. code-block:: python
# Old API
from webargs import Arg
args = {
'name': Arg(str, required=True)
'password': Arg(str, validate=lambda p: len(p) >= 6),
'display_per_page': Arg(int, default=10),
'nickname': Arg(multiple=True),
'Content-Type': Arg(dest='content_type', location='headers'),
'location': Arg({
'city': Arg(str),
'state': Arg(str)
})
}
# New API
from webargs import fields
args = {
'name': fields.Str(required=True)
'password': fields.Str(validate=lambda p: len(p) >= 6),
'display_per_page': fields.Int(missing=10),
'nickname': fields.List(fields.Str()),
'content_type': fields.Str(load_from='Content-Type'),
'location': fields.Nested({
'city': fields.Str(),
'state': fields.Str()
})
}
Features:

* Error messages for all arguments are "bundled" (:issue:`58`).

Changes:

* *Backwards-incompatible*: Replace ``Args`` with marshmallow fields (:issue:`61`).
* *Backwards-incompatible*: When using ``use_kwargs``, missing arguments will have the special value ``missing`` rather than ``None``.
* ``TornadoParser`` raises a custom ``HTTPError`` with a ``messages`` attribute when validation fails.

Bug fixes:

* Fix required validation of nested arguments (:issue:`39`, :issue:`51`). These are fixed by virtue of using marshmallow's ``Nested`` field. Thanks :user:`ewang` and :user:`chavz` for reporting.

Support:

* Updated docs.

0.15.0 (2015-08-22)
*******************

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ webargs is a Python library for parsing HTTP request arguments, with built-in su
.. code-block:: python
from flask import Flask
from webargs import Arg
from webargs import fields
from webargs.flaskparser import use_args
app = Flask(__name__)
hello_args = {
'name': Arg(str, required=True)
'name': fields.Str(required=True)
}
@app.route('/')
Expand Down
5 changes: 5 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ webapp2>=2.5.2

# Syntax checking
flake8==2.4.0

# TODO: Remove me
# webargs will eventually depend on 2.0 final
# Depend on dev branch until it's released
git+https://github.com/marshmallow-code/marshmallow.git@dev
25 changes: 0 additions & 25 deletions docs/_templates/side-primary.html

This file was deleted.

24 changes: 0 additions & 24 deletions docs/_templates/side-secondary.html

This file was deleted.

46 changes: 6 additions & 40 deletions docs/_themes/LICENSE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
Modifications:

Copyright (c) 2010 Kenneth Reitz.


Original Project:

Copyright (c) 2010 by Armin Ronacher.

Copyright (c) Juan-Pablo Scaletti

Some rights reserved.

Redistribution and use in source and binary forms of the theme, with or
without modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
Redistribution and use in source and binary forms of the software as well as documentation, with or without modification, are permitted provided that the following conditions are met:

We kindly ask you to only use these themes in an unmodified manner just
for Flask and Flask-related products, not for unrelated projects. If you
like the visual style and want to use it for your own projects, please
consider making some larger changes to the themes (such as changing
font faces, sizes, colors or margins).
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86 changes: 0 additions & 86 deletions docs/_themes/flask_theme_support.py

This file was deleted.

20 changes: 0 additions & 20 deletions docs/_themes/kr/layout.html

This file was deleted.

20 changes: 0 additions & 20 deletions docs/_themes/kr/relations.html

This file was deleted.

0 comments on commit 5b3277b

Please sign in to comment.