changeset 966:12c149171199

pages (data post): pages can now be redirected to a other uri than current page, using request.data['post_redirect_uri']
author Goffi <goffi@goffi.org>
date Sun, 05 Nov 2017 20:32:29 +0100
parents 8f2c1ea36e96
children 4d1dcf97740f
files src/server/server.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/server/server.py	Sun Nov 05 20:31:18 2017 +0100
+++ b/src/server/server.py	Sun Nov 05 20:32:29 2017 +0100
@@ -1660,7 +1660,8 @@
     def _on_data_post_redirect(self, ret, request):
         """called when page's on_data_post has been called successfuly
 
-        this method redirect to the same page, using Post/Redirect/Get pattern
+        this method redirect to the same page or to request.data['post_redirect_uri']
+        if it is set, using Post/Redirect/Get pattern.
         HTTP status code "See Other" (303) is the recommanded code in this case
         @param ret(None, unicode, iterable): on_data_post return value
             see LiberviaPage.__init__ on_data_post docstring
@@ -1676,7 +1677,7 @@
         if not C.POST_NO_CONFIRM in ret:
             session_data.setPageFlag(self, C.FLAG_CONFIRM)
         request.setResponseCode(C.HTTP_SEE_OTHER)
-        request.setHeader("location", request.uri)
+        request.setHeader("location", request.data.get('post_redirect_uri', request.uri))
         request.finish()
         raise failure.Failure(exceptions.CancelError(u'Post/Redirect/Get is used'))