Mercurial > libervia-web
comparison src/server/server.py @ 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 | fd4eae654182 |
children | 4d37b23777c3 |
comparison
equal
deleted
inserted
replaced
965:8f2c1ea36e96 | 966:12c149171199 |
---|---|
1658 self.pageError(request, C.HTTP_INTERNAL_ERROR) | 1658 self.pageError(request, C.HTTP_INTERNAL_ERROR) |
1659 | 1659 |
1660 def _on_data_post_redirect(self, ret, request): | 1660 def _on_data_post_redirect(self, ret, request): |
1661 """called when page's on_data_post has been called successfuly | 1661 """called when page's on_data_post has been called successfuly |
1662 | 1662 |
1663 this method redirect to the same page, using Post/Redirect/Get pattern | 1663 this method redirect to the same page or to request.data['post_redirect_uri'] |
1664 if it is set, using Post/Redirect/Get pattern. | |
1664 HTTP status code "See Other" (303) is the recommanded code in this case | 1665 HTTP status code "See Other" (303) is the recommanded code in this case |
1665 @param ret(None, unicode, iterable): on_data_post return value | 1666 @param ret(None, unicode, iterable): on_data_post return value |
1666 see LiberviaPage.__init__ on_data_post docstring | 1667 see LiberviaPage.__init__ on_data_post docstring |
1667 """ | 1668 """ |
1668 if ret is None: | 1669 if ret is None: |
1674 raise NotImplementedError(_(u'iterable in on_data_post return value is not used yet')) | 1675 raise NotImplementedError(_(u'iterable in on_data_post return value is not used yet')) |
1675 session_data = self.host.getSessionData(request, session_iface.ISATSession) | 1676 session_data = self.host.getSessionData(request, session_iface.ISATSession) |
1676 if not C.POST_NO_CONFIRM in ret: | 1677 if not C.POST_NO_CONFIRM in ret: |
1677 session_data.setPageFlag(self, C.FLAG_CONFIRM) | 1678 session_data.setPageFlag(self, C.FLAG_CONFIRM) |
1678 request.setResponseCode(C.HTTP_SEE_OTHER) | 1679 request.setResponseCode(C.HTTP_SEE_OTHER) |
1679 request.setHeader("location", request.uri) | 1680 request.setHeader("location", request.data.get('post_redirect_uri', request.uri)) |
1680 request.finish() | 1681 request.finish() |
1681 raise failure.Failure(exceptions.CancelError(u'Post/Redirect/Get is used')) | 1682 raise failure.Failure(exceptions.CancelError(u'Post/Redirect/Get is used')) |
1682 | 1683 |
1683 def _on_data_post(self, dummy, request): | 1684 def _on_data_post(self, dummy, request): |
1684 csrf_token = self.host.getSessionData(request, session_iface.ISATSession).csrf_token | 1685 csrf_token = self.host.getSessionData(request, session_iface.ISATSession).csrf_token |