Skip to main content

A Request parsing interface designed to provide simple and uniform access to any variable on the webapp2.Request object in Webapp2

Project description

https://travis-ci.org/ekampf/webapp2_restful.svg https://coveralls.io/repos/ekampf/webapp2_restful/badge.svg?branch=master&service=github https://img.shields.io/pypi/v/webapp2_restful.svg

The webapp2_restful library is a Request parsing interface inspired by restful-flask’s request parser.

Its interface is modeled after the argparse interface.

Its goal is to provide a uniform access to any variable on the webapp2.Request object and allowing handlers to provide a sort of “contract” where they specify the parameters they expect to be called with - making code easier to read and understand.

Basic Argument Parsing

Here’s a simple example of the request parser. It looks for two arguments in the webapp2.Request’s json and params properties: one of type int, and the other of type str:

from webapp2_restful.parser import RequestParser

parser = RequestParser()
parser.add_argument('rate', type=int, help='Rate cannot be converted')
parser.add_argument('name', type=str)
args = parser.parse_args(self.request)

Special Google AppEngine Arguments

from webapp2_restful.parser import RequestParser
from webapp2_restful.arguments_ndb import EntityIDArgument

parser = RequestParser()
parser.add_argument('store_id', type=EntityIDArgument(Store), dest='store')
args = parser.parse_args(self.request)

# args.store is a Store instance
print(args.store)

History

0.1.0 (2015-01-11)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for webapp2_restful, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size webapp2_restful-0.1.1-py2.py3-none-any.whl (6.3 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes
Filename, size webapp2_restful-0.1.1.tar.gz (18.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page