Added pillar.api.utils.bsonify(some_dict)
It was used in an experiment in Flamenco as an alternative to JSON; it might still be used in the future if BSON turns out to be significantly faster to generate.
This commit is contained in:
@@ -85,6 +85,18 @@ def jsonify(mongo_doc, status=200, headers=None):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
|
|
||||||
|
def bsonify(mongo_doc, status=200, headers=None):
|
||||||
|
"""BSonifies a Mongo document into a Flask response object."""
|
||||||
|
|
||||||
|
import bson
|
||||||
|
|
||||||
|
data = bson.BSON.encode(mongo_doc)
|
||||||
|
return current_app.response_class(data,
|
||||||
|
mimetype='application/bson',
|
||||||
|
status=status,
|
||||||
|
headers=headers)
|
||||||
|
|
||||||
|
|
||||||
def skip_when_testing(func):
|
def skip_when_testing(func):
|
||||||
"""Decorator, skips the decorated function when app.config['TESTING']"""
|
"""Decorator, skips the decorated function when app.config['TESTING']"""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user