Skip to content

Instantly share code, notes, and snippets.

@Raistlfiren
Created April 2, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raistlfiren/cedac5e6c04a752cd9957374559db5f3 to your computer and use it in GitHub Desktop.
Save Raistlfiren/cedac5e6c04a752cd9957374559db5f3 to your computer and use it in GitHub Desktop.
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