def correlation(correlation_id): """Returns the JSON representation of the requested correlation.""" try: correlation = Correlation.find_one(bson.ObjectId(correlation_id)) if not correlation: abort(404) correlation = OrderedDict([(key, correlation[key] ) for key in ['interval', 'start', 'end', 'correlation', 'paths', 'group_by']]) except bson.errors.InvalidId: abort(404) protected_func = (lambda x: x) # Wrap the return function in the appropriate realm checks. for path in correlation['paths']: protected_funct = PROVIDER.require_oauth( realm = path.split("/")[0])(protected_func) return protected_func(json.dumps( correlation, cls = correlations.jsonencoder.JSONEncoder))