Example #1
0
 def relativePath(self, toPath):
     """
         Return a relative path to a page specified by a list of path
         components. The argument should be a full path relative to the root
         of this application.
     """
     common = 0
     fromPath = [i.name for i in self.structuralPath()]
     for common, e in enumerate(zip(fromPath, toPath)):
         if not e[0] == e[1]:
             break
     backtrack = [".."]*((len(fromPath) - 1)-common)
     return utils.urlCat(*(backtrack + toPath[common:]))
Example #2
0
    def __str__(self):
        to = state.application.getPage(self.pageSpec)
        if not to:
            s = "Link to unknown page: %s."%self.pageSpec
            raise ApplicationError(s)
        if to.internal:
            s = "URL request to internal page: %s."%to.name
            raise ApplicationError(s)

        absdomain = state.page.findAttr("absolute_domain", None)
        if absdomain:
            u = to.absolutePath()
            u = utils.urlCat(to.siteUrl(), u)
        else:
            rel = state.page.relativePath([i.name for i in to.structuralPath()])
            u = utils.makeURL(rel)

        if self.anchor:
            u = u + "#%s"%self.anchor
        return u
Example #3
0
 def absolutePath(self):
     p = [i.name for i in self.structuralPath()]
     return utils.urlCat(*p)
Example #4
0
 def __str__(self):
     return utils.urlCat("./", state.page.top())