Permalink
Browse files

return 404 when item was not found (used to work before?)

  • Loading branch information...
1 parent add876c commit e305fad01bb816be19d05802f96dd96635e1d021 @tgpfeiffer committed Jan 13, 2013
Showing with 10 additions and 1 deletion.
  1. +10 −1 restfulOpenErpProxy.py
View
@@ -228,6 +228,8 @@ def __getLastItemUpdate(self, uid, request, pwd, modelId):
modelId = -1
proxy = Proxy(self.openerpUrl + 'object')
def handleLastItemUpdateAnswer(updateAnswer):
+ if not updateAnswer:
+ raise NotFound(str(request.URLPath()))
return (uid, updateAnswer[0]['__last_update'])
d = proxy.callRemote('execute', self.dbname, uid, pwd, self.model, 'read', [modelId], ['__last_update'])
d.addCallback(handleLastItemUpdateAnswer)
@@ -755,7 +757,7 @@ def __cleanup(self, err, request):
else:
request.setResponseCode(500)
request.write("An XML-RPC error occured:\n"+e.faultCode.encode("utf-8"))
- elif e.__class__ in (InvalidParameter, PostNotPossible, NoChildResources):
+ elif e.__class__ in (InvalidParameter, PostNotPossible, NoChildResources, NotFound):
request.setResponseCode(e.code)
request.write(str(e))
else:
@@ -869,6 +871,13 @@ def __init__(self, res):
def __str__(self):
return str(self.res) + " has no child resources"
+class NotFound(Exception):
+ code = 404
+ def __init__(self, res):
+ self.res = res
+ def __str__(self):
+ return str(self.res) + " was not found"
+
if __name__ == "__main__":
# read config

0 comments on commit e305fad

Please sign in to comment.