Mercurial > libervia-web
changeset 955:4f7cb6335a33
server(pages): do Post/Redirect/Get pattern when on_data_post is used (avoid double posting on refresh)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Jul 2017 22:28:40 +0200 |
parents | 7892f1a1e2cf |
children | dabecab10faa |
files | src/server/server.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/server/server.py Fri Jul 07 07:28:42 2017 +0200 +++ b/src/server/server.py Sun Jul 09 22:28:40 2017 +0200 @@ -1690,8 +1690,14 @@ msg = failure_)) self.pageError(request, C.HTTP_INTERNAL_ERROR) + @defer.inlineCallbacks def _on_data_post(self, dummy, request): - return defer.maybeDeferred(self.on_data_post, self, request) + yield defer.maybeDeferred(self.on_data_post, self, request) + request.setResponseCode(303) + request.setHeader("location", request.uri) + request.finish() + raise failure.Failure(exceptions.CancelError(u'Post/Redirect/Get is used')) + def getPostedData(self, request, keys, multiple=False): """get data from a POST request and decode it