Created
April 2, 2016 15:02
-
-
Save Raistlfiren/cedac5e6c04a752cd9957374559db5f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Filters(object): | |
def __init__(self, types=[], query=None): | |
self.types = types | |
self.query = query | |
def __call__(self, *args, **kwargs): | |
for type in self.types: | |
try: | |
func = getattr(Filters, type) | |
except AttributeError: | |
print ('function not found') | |
else: | |
func(object, self.query) | |
def filter(self, query): | |
with app.app_context(): | |
from flask import request | |
filters, err = FilterParameter.generate(PlayerSchema, request.args) | |
query = FilterParameter.filter_core_by(query, filters) | |
@Filters(['filter'], select([Login.id, Login.login])) | |
@app.route('/players', methods=['GET']) | |
def players(result): | |
return PlayerSchema(many=True).dump(result).data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment