Hi all,

I have ExtraPathInfo turned on in my Application.config file and, currently, to get the actual URL of the current servlet I have to do something like this:

class MyPage(Page):
        def awake (self, transaction):
                Page.awake (self, transaction)
                self.extraURLItems = self.request().extraURLPath().split('/')[1:]
                self.servletPath = '%s/%s/%s' % (
                        # the name apache uses to redirect to webkit:
                                self.request().servletPath(),
                        # the name of the context:
                                self.request().pathInfo().split('/')[0],
                        # the name of this servlet:
                                self.request().servletPathFromSiteRoot().split('/')[0],
                        #  alternately, the last item could just be:
                        #  self.__class__.name
                                )

This would mean that http://127.0.0.1/WK/Context1/MyPage/Item/200 would produce servletPath = '/WK/Context1/MyPage'.

The bottom line is: I need to get the absolute URL to prefix all links produced by 'MyPage' since relative URLs just add onto the URL such that
<a href="OtherItem/400">400</a> is interpreted as:
'http://127.0.0.1/WK/Context1/MyPage/Item/OtherItem/400', and
<a href="/OtherItem/400">400</a> is interpreted as:
'http://127.0.0.1/OtherItem/400'.


I could always do this: <a href="../OtherItem/400"> but it doesn't seem intuitive. I'd rather have '''<a href="%s/OtherItem/400">''' % self.servletPath

Is there a better/simpler way to get at it than this?

Thanks,
Tracy

P.S. I saw that request().contextPath() raises a 'Not Implented' error. Will that function eventually return '/WK/Context1' in my example above?



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to