def json_view(f):
 @wraps(f)
 def _wrapped(req, *a, **kw):
  try:
   ret = f(req, *a, **kw)
   blob = json.dumps(ret)
   return http.HttpResponse(blob, content_type=JSON)
  except http.Http404 as e:
   blob = json.dumps({'success': False, 'error': 404, 'message': str(e)})
   return http.HttpResponseNotFound(blob, content_type=JSON)
  except PermissionDenied as e:
   blob = json.dumps({'success': False, 'error': 403, 'message': str(e)})
   return http.HttpResponseForbidden(blob, content_type=JSON)
  except Exception as e:
   blob = json.dumps({'success': False, 'error': 500, 'message': str(e)})
   return http.HttpResponseServerError(blob, content_type=JSON)
 return _wrapped

def json_view ( f ) : @ wraps ( f ) def _wrapped ( req , * a , ** kw ) : try : ret = f ( req , * a , ** kw ) blob = json . dumps ( ret ) return http . HttpResponse ( blob , content_type = JSON ) except http . Http404 as e : blob = json . dumps ( { 'success' : False , 'error' : 404 , 'message' : str ( e ) } ) return http . HttpResponseNotFound ( blob , content_type = JSON ) except PermissionDenied as e : blob = json . dumps ( { 'success' : False , 'error' : 403 , 'message' : str ( e ) } ) return http . HttpResponseForbidden ( blob , content_type = JSON ) except Exception as e : blob = json . dumps ( { 'success' : False , 'error' : 500 , 'message' : str ( e ) } ) return http . HttpResponseServerError ( blob , content_type = JSON ) return _wrapped
return some basic document info in a json blob .