comparison src/server/server.py @ 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 67a59552f3e3
children dabecab10faa
comparison
equal deleted inserted replaced
954:7892f1a1e2cf 955:4f7cb6335a33
1688 log.error(_(u"Uncatched error for HTTP request on {url}: {msg}").format( 1688 log.error(_(u"Uncatched error for HTTP request on {url}: {msg}").format(
1689 url = request.URLPath(), 1689 url = request.URLPath(),
1690 msg = failure_)) 1690 msg = failure_))
1691 self.pageError(request, C.HTTP_INTERNAL_ERROR) 1691 self.pageError(request, C.HTTP_INTERNAL_ERROR)
1692 1692
1693 @defer.inlineCallbacks
1693 def _on_data_post(self, dummy, request): 1694 def _on_data_post(self, dummy, request):
1694 return defer.maybeDeferred(self.on_data_post, self, request) 1695 yield defer.maybeDeferred(self.on_data_post, self, request)
1696 request.setResponseCode(303)
1697 request.setHeader("location", request.uri)
1698 request.finish()
1699 raise failure.Failure(exceptions.CancelError(u'Post/Redirect/Get is used'))
1700
1695 1701
1696 def getPostedData(self, request, keys, multiple=False): 1702 def getPostedData(self, request, keys, multiple=False):
1697 """get data from a POST request and decode it 1703 """get data from a POST request and decode it
1698 1704
1699 @param request(server.Request): request linked to the session 1705 @param request(server.Request): request linked to the session