예제 #1
0
 def PUT(self, request, tenantId):
     try:
         info = InfoManager.InfoManager().get_information(tenantId)
         self.set_info(info)
         info2 = self.info.parse(request.body)
         if info2 != None:
             t = InfoManager.InfoManager().updateWindowSize(tenantId, info2.windowsize)
             logger.debug("Window size updated for tenant: %s", tenantId)
             return HttpResponse(json.dumps({"windowsize": info2.windowsize}, indent=4))
         else:
             return HttpResponseBadRequest(json.dumps({"badRequest": {"code": 400, "message":
                     "windowsize could not be parsed"}}, indent=4))
     except ObjectDoesNotExist as err:
         t = TenantInfo(tenantId=tenantId, windowsize=5)
         t.save()
         info = InfoManager.InfoManager().get_information(tenantId)
         self.set_info(info)
         info2 = self.info.parse(request.body)
         t = InfoManager.InfoManager().updateWindowSize(tenantId, info2.windowsize)
         return HttpResponse(json.dumps({"windowsize": info2.windowsize}, indent=4))
     except ValidationError as ex:
             return HttpResponse(json.dumps({"badRequest": {"code": 400, "message":
                 ex.messages[0]}}, indent=4), status=400)
     except ValueError as ex:
             return HttpResponse(json.dumps({"badRequest": {"code": 400, "message":
                 ex.message}}, indent=4), status=400)
예제 #2
0
 def GET(self, request, tenantId):
     try:
         info = InfoManager.InfoManager().get_information(tenantId)
         return HttpResponse(json.dumps(info.getVars(), indent=4))
     except ObjectDoesNotExist as err:
         print str(err)
         t = TenantInfo(tenantId=tenantId, windowsize=5)
         t.save()
         info = InfoManager.InfoManager().get_information(tenantId)
         return HttpResponse(json.dumps(info.getVars(), indent=4))