On Wednesday, October 22, 2003, at 10:15 AM, Tracy S. Ruggles wrote:
> Is there a better way to force a trailing '/' in the URL of a
> particular servlet than this code:
>
> # ---------- MyPage.py
>
> from WebKit.Page import Page
>
> class MyPage(Page):
>
> def awake(self, transaction):
> '''Force a trailing '/' at the end of the URL'''
> Page.awake(self, transaction)
> if self.request().uri().split('/')[-1] == self.__class__.__name__:
> self.sendRedirectAndEnd(self.__class__.__name__ + '/')
Maybe a little:
def awake(self, trans):
Page.awake(self, trans)
if not self.request().extraURLPath():
self.sendRedirect(self.request().environ()['REQUEST_URI'] +
'/')
... Not sure about that last line, you'll have to test.
--
Ian Bicking | ianb@... | http://blog.ianbicking.org
|