Exemplo n.º 1
0
 def jsonrpc_upsert(self, lst):
     try:
         b = Backend()
         result = yield b.upsert(lst)
         defer.returnValue(result)
     except exception.ModelNotExistError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.MissingFieldError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.KeyNotDefinedError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.ConstraintViolationError as e:
         defer.returnValue(Fault(exception.CONSTRAINT_VIOLATION, str(e)))
     except Exception as e:
         raise
Exemplo n.º 2
0
 def jsonrpc_update(self, item):
     try:
         b = Backend()
         if isinstance(item, dict):
             item['path'] = self.path
             resp = yield b.upsert([item])
             defer.returnValue(resp)
         else:
             defer.returnValue(Fault(exception.INVALID_INPUT,
                                     "content must be json dict"))
     except exception.MissingFieldError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.ModelNotExistError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.KeyNotDefinedError as e:
         defer.returnValue(Fault(exception.INVALID_INPUT, str(e)))
     except exception.ConstraintViolationError as e:
         defer.returnValue(Fault(exception.CONSTRAINT_VIOLATION, str(e)))
     except:
         raise
Exemplo n.º 3
0
    def async_POST(self, request):
        b = Backend()

        self.postdata['path'] = self.path
        result = yield b.upsert([self.postdata])
        defer.returnValue(RESTResult(code=200, content=result))