Comment 13 for bug 101098

Revision history for this message
Samuel Schluep (schluep) wrote :

This is still an open issue and we have Silva 1.4 now! I have some code, which
also works in virtual hosting situations (probably the smart guys from Infrae
could provide much more elegant code ;-). It works also for hires images that
are outside the virtual host, but in the same Silva instance (thanks to
acquisition). However, I doubt that this can be used for XSLT rendering.
Therefore a more general linking review is still needed.

is_url = link.split('://')
if not (link == '' or link == None) and len(is_url) == 1:
    # it's not a url, make path absolute if it is not already
    link_path = link.split('/')
    model_path = context.REQUEST.model.getPhysicalPath()
    link_path = mangle.Path.toAbsolute(model_path, link_path)
    # adapt path for virtual hosting
    virtual_root_path = context.REQUEST.get('VirtualRootPhysicalPath', [])
    # ommit the virtual root base path
    i = 0
    while i < len(virtual_root_path):
        if link_path[i] != virtual_root_path[i]:
            i = -1
            break
        i += 1
    if i > -1:
        link_path[1:i] = []
    link = '/'.join(link_path)