Bottle.py Querystring smart guessing
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bottle_smart_filters
test
.gitignore
.travis.yml
LISENCE
README.rst
example.py
requirements.txt
setup.py

README.rst

bottle-smart-filters: Bottle Querystring smart guessing

Provides a bottle.py plugin for querystring parameters smart guessing.

Features:

  • Provides default type casting for integers, floats, booleans (of course strings).
  • Supports JSON params (i.e Elastic Search URL's like GET /?q={"id": 34, "age": 39})
  • Provides a mechanism for multiple value params through separators.
  • Smart filter callback is attached to bottle.Bottle.request.query instance, so it doesn't mess your implementation.
  • Useful Pre-processor for any validation library or custom implementation.

Note

This is NOT A Querystring validation library!

https://travis-ci.org/agile4you/bottle-smart-filters.svg?branch=master https://coveralls.io/repos/agile4you/bottle-smart-filters/badge.svg?branch=master&service=github

Example Usage

import bottle
from bottle.ext.smart_filters import SmartFiltersPlugin

bottle.install(SmartFiltersPlugin())

@bottle.get('/')
def index():
    return {'smart_filters': bottle.request.query.smart_filters()}


bottle.run()

Example URL's:

- GET /?id=12434&membership=true&score=9.4&email=someone@somewhere.com
    * Smart Filter output:
      {"id": 12343, "member": True, "score": 9.4, "email": "someone@somewhere.com"}

- GET /?numbers=1,2, 3,4,&gps={"lat": 33.093, "lng": "23.090"}
    * Smart Filter output:
      {"number": [1, 2, 3, 4, 5], "gps": {"lat": 33.093, "lng": "23.090"}}