'Returns absolutized URL in respect to base URL as per
RFC 3986. If url is already absolute (with scheme), return url.
@param base: base URL of original document
@param url: URL to be resolved against base URL'

def absolutizeUrl(self, base, url):

    resolved = urlparse.urljoin(base, url)
    resolvedParsed = urlparse.urlparse(resolved)
    path = resolvedParsed.path
    if ((path == '') or (not path.startswith('/'))):
        return resolved
    pathParts = path[1:].split('/')
    while ((len(pathParts) > 0) and (pathParts[0] in ('.', '..'))):
        pathParts = pathParts[1:]
    if (len(pathParts) > 0):
        newPath = ('/' + '/'.join(pathParts))
    else:
        newPath = '/'
    urlParts = ((resolvedParsed[0:2] + (newPath,)) + resolvedParsed[3:6])
    newUrl = urlparse.urlunparse(urlParts)
    return newUrl
