This is working for me, even when I forward to a servlet in a different
directory.  Give it a try and let me know if it works.

Perhaps this ought to be added to SitePage.

    def siteRoot(self):
        """
        Returns the URL path components necessary to get back
        home from the current location.  Works even if you have
        forwarded from one servlet to another.
        """
        req = self.request()
        url = req.pathInfo()
        contextName = req.contextName() + '/'
        if url.startswith(contextName):
            url = url[len(contextName):]
        numStepsBackward = len(url.split('/')) - 1
        return '../' * numStepsBackward

- Geoff


> -----Original Message-----
> From: Luke Opperman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 30, 2002 5:41 PM
> To: Webware Discuss
> Subject: [Webware-discuss] Directory-depth and Forwards
> 
> 
> Hi there -
> 
> Let's see if I can describe my problems.
> 
> First, imaginary directory structure:
> 
> Context1/
>          styles/
>                 sitestyles.css
>          Main.py
>          staff/
>                Welcome.py
>                Email/
>                      Send.py
> 
> Now, say all these pages (Main.py, Welcome.py, Send.py)
> inherit from my SitePage, which defines writeStyleSheet()
> to include the sitestyles.css file. How do you manage the
> relative nature of this URL as the pages descend into
> directories?
> 
> Option 1: each page defines a function/accessor that
> returns the appropriate relative prefix to get back to root
> ("../", "../../"). Anytime I need a site-wide relative url,
> prepend self.dots() to the site-root relative url. However,
> this currently breaks if I use application.forward() (for
> example, as SecurePage does), as it is the forwarded page's
> dots() method that is called.
> 
> Option 2: set a request(?) variable in awake for the
> relative prefix, then prepend that (or have dots() return
> that). If it already exists, don't set it (so that the
> forwarded page doesn't overwrite). Set this in awake for
> the class. Is there any problem concern I'm not thinking
> about in setting a request field?
> 
> Or some third option that hasn't occurred to me yet. How do
> you deal with this?
> 
> Luke
> 
> =====
> ------------------
> Reference Counting Garbage Collection:
> Look out philosophy majors, things really DO
> cease to exist when no one is looking at them!
> ------------------
> 
> __________________________________________________
> Do You Yahoo!?
> Great stuff seeking new owners in Yahoo! Auctions! 
> http://auctions.yahoo.com
> 
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
> 

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to