Falcon filtering helper
Project description
A small falcon hook to parse filtering elements from the request.
Usage
The easiest way to use this hook is the following:
class Resource:
filtering_fields = ("foo", "bar") # List of fields allowed for filtering
@falcon.before(FilteringHook())
def on_get(self, req, resp, user):
# Here req['context']['filters'] is set
The Hook will look in the query parameters for parameters looking like filter[key]=value.
It will create a filters dict into the request context accessible at req.context['filters'].
Inside this dict the key will be the one extracted from between the brackets.
i.e. key in the example above.
Configuration options
Allowing fields to be filtered
For security reasons, the fields allowed for filtering must be specified in the filtering_fields attribute of the resource.
All the fields not defined in it will be discarded by the hook.
Hook configuration
One parameter can be passed to the hook:
filtering_key : The base name of the key used for the filters. Default:
filter.
Example:
@falcon.before(PaginationFromRequestHook(
filtering_key='custom_filter',
))
def on_get(self, req, resp, user):
# Get request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file falcon_filtering-0.2.0.tar.gz.
File metadata
- Download URL: falcon_filtering-0.2.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b17e6c345da4a057ce22f5b77db96527133a7b271425f8daf527cc7aa0ec606
|
|
| MD5 |
df123bfb96380eabf1942b310b296463
|
|
| BLAKE2b-256 |
26e0fa9bd83ca338ff80fb56a8f0c1aaca16c8710cf8a434ee4e5d90f9521f6f
|
File details
Details for the file falcon_filtering-0.2.0-py3-none-any.whl.
File metadata
- Download URL: falcon_filtering-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c130ef5b1b6fd883b5ed4148993c8e0cae816aa68a047acd6f6dbb28e89758
|
|
| MD5 |
91d5e069ed5b00469b47d04e35d26245
|
|
| BLAKE2b-256 |
65eb13cfacc421485de2f00aca0c2e35f8eaa9bddb44b8fd6b1ee81e0c04e49e
|