comparison src/server/pages.py @ 1015:16d52917666c

pages: fixed redirection
author Goffi <goffi@goffi.org>
date Fri, 19 Jan 2018 18:01:58 +0100
parents dfced7992460
children 78af5457d3f8
comparison
equal deleted inserted replaced
1014:dfced7992460 1015:16d52917666c
368 return os.path.join('/', url_base, remaining_url) 368 return os.path.join('/', url_base, remaining_url)
369 369
370 return os.path.join(self.url, *url_args) 370 return os.path.join(self.url, *url_args)
371 371
372 def getCurrentURL(self, request): 372 def getCurrentURL(self, request):
373 """retrieve URL use to access this page 373 """retrieve URL used to access this page
374 374
375 @return(unicode): current URL 375 @return(unicode): current URL
376 """ 376 """
377 # we get url in the following way (splitting request.path instead of using 377 # we get url in the following way (splitting request.path instead of using
378 # request.prepath) because request.prepath may have been modified by 378 # request.prepath) because request.prepath may have been modified by
653 if redirect_page is self.host.root: 653 if redirect_page is self.host.root:
654 redirect_page = redirect_page.children[subpage] 654 redirect_page = redirect_page.children[subpage]
655 else: 655 else:
656 redirect_page = redirect_page.original.children[subpage] 656 redirect_page = redirect_page.original.children[subpage]
657 657
658 redirect_page.renderPage(request, skip_parse_url=True) 658 redirect_page.renderPage(request, skip_parse_url=skip_parse_url)
659 raise failure.Failure(exceptions.CancelError(u'page redirection is used')) 659 raise failure.Failure(exceptions.CancelError(u'page redirection is used'))
660 660
661 def pageError(self, request, code=C.HTTP_NOT_FOUND): 661 def pageError(self, request, code=C.HTTP_NOT_FOUND):
662 """generate an error page and terminate the request 662 """generate an error page and terminate the request
663 663
967 967
968 d = defer.Deferred() 968 d = defer.Deferred()
969 d.addCallback(self._checkAccess, request) 969 d.addCallback(self._checkAccess, request)
970 970
971 if self.redirect is not None: 971 if self.redirect is not None:
972 self.pageRedirect(self.redirect, request, skip_parse_url=False) 972 d.addCallback(lambda dummy: self.pageRedirect(self.redirect, request, skip_parse_url=False))
973 973
974 if self.parse_url is not None and not skip_parse_url: 974 if self.parse_url is not None and not skip_parse_url:
975 d.addCallback(self.parse_url, request) 975 d.addCallback(self.parse_url, request)
976 976
977 d.addCallback(self._subpagesHandler, request) 977 d.addCallback(self._subpagesHandler, request)