Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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