def items(query=None, user=LOGGED_IN_USER, username=USER): """ Given an LQL query and a library identity, return the items that match. """ library = Library.objects.get() items = Item.objects.all() query_json = '[]' if query: from query import execute_query, parse_query parsed = parse_query(query) items = execute_query(items, parsed) # this json representation of the query that was just used to filter # the items will be passed back to the template as a json string # so the front end can render the query widget. A string representation # is not passed because there is no way to parse LQL in javascript (yet). query_json = jsonify(parsed) items = items.all() all_keys = [] return { 'parsed_query_json': query_json, 'library_items': items, 'items_count': len(items), 'keys': all_keys, }
def generic_json(self, result, errors): return {'body': jsonify(result), 'mimetype': 'application/json'}
def renderer(self, data, errors): return jsonify(data)