# HG changeset patch # User Goffi # Date 1499632120 -7200 # Node ID 4f7cb6335a33e036576121c3354141f218a21ede # Parent 7892f1a1e2cf1c8b70a36e94a40faf1c8562b68b server(pages): do Post/Redirect/Get pattern when on_data_post is used (avoid double posting on refresh) diff -r 7892f1a1e2cf -r 4f7cb6335a33 src/server/server.py --- 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