def dispatch(req, data_path): valid = auth.validate_request(req) if valid is not True: return valid if settings.DEBUG: logging.debug('='*60) logging.debug("User: %s" % req.user) logging.debug("Method: %s" % req.method) logging.debug("Data path: %s" % data_path) try: logging.debug("%s: %s" % (req.method, getattr(req, req.method))) except: pass start_time = time.time() # get handler if req.method not in ('GET','POST', 'PUT','DELETE'): raise Http404 try: handler = globals()['__%s' % req.method] except KeyError: raise Http404 # execute handler try: ret = handler(req, data_path) except Http404: raise except Exception, e: raise msg = 'HDLR ERROR: %s %s' % (req.method, data_path) if settings.DEBUG: msg += ': %s' % e logging.debug(msg) return HttpResponseServerError(msg)
def dispatch(req, rpc_path): valid = auth.validate_request(req) if valid is not True: return valid # respond only to POST requests if req.method != 'POST': raise Http404 try: path = rpc_path.split('/') if len(path) < 2: raise Exception func_name = path[-1] path = '.'.join(path[:-1]) except Exception, e: msg = "Invalid request" if settings.DEBUG: msg += ": %s (%s)" % (e, rpc_path) return HttpResponseServerError(msg)
def dispatch(req, data_path): valid = auth.validate_request(req) if valid is not True: return valid if settings.DEBUG: logging.debug('=' * 60) logging.debug("User: %s" % req.user) logging.debug("Method: %s" % req.method) logging.debug("Data path: %s" % data_path) try: logging.debug("%s: %s" % (req.method, getattr(req, req.method))) except: pass start_time = time.time() # get handler if req.method not in ('GET', 'POST', 'PUT', 'DELETE'): raise Http404 try: handler = globals()['__%s' % req.method] except KeyError: raise Http404 # execute handler try: ret = handler(req, data_path) except Http404: raise except Exception, e: raise msg = 'HDLR ERROR: %s %s' % (req.method, data_path) if settings.DEBUG: msg += ': %s' % e logging.debug(msg) return HttpResponseServerError(msg)