예제 #1
0
 def __call__(self, environ, start_response):
     req = Request(environ)
     resp = Response(content_type="application/json")
     resp.dict = {}
     try:
         req.dict = json.loads(req.body)
         if self.mode == "debug":
             protobuf_json.json2pb(taggit_pb.JsonRequest(), req.dict)
         handler = getattr(self, environ['_HANDLER'])
         handler(req, resp)  # handle !
         if self.mode == "debug":
             protobuf_json.json2pb(taggit_pb.JsonResponse(), resp.dict)
     except Exception, e:
         print '(E) JsonApp call:', e
예제 #2
0
 def __call__(self, environ, start_response):
     req = Request(environ)
     resp = Response(content_type="application/json")
     resp.dict = {}
     try:
         req.dict = json.loads(req.body)
         if self.mode == "debug":
             protobuf_json.json2pb(taggit_pb.JsonRequest(), req.dict)
         handler = getattr(self,environ['_HANDLER'])
         handler(req,resp) # handle !
         if self.mode == "debug":
             protobuf_json.json2pb(taggit_pb.JsonResponse(), resp.dict)
     except Exception, e:
         print '(E) JsonApp call:', e