Exemple #1
0
def uriSplitZopeDebug(filename, filepath):
    # zopedebug://[host[:port]]/[path]/[meta type]
    # magically maps zopedebug urls to Boa zope uris
    segs = filepath.split('/')
    if len(segs) < 3:
        raise ExplorerNodes.TransportCategoryError('Zope debug path invalid',
                                                   filepath)
    host, filepaths, meta = segs[0], segs[1:-1], segs[-1]
    try:
        host, port = host.split(':')
    except ValueError:
        port = 80
    else:
        port = int(port)
    # try to find category that can open this url
    for cat in ExplorerNodes.all_transports.entries:
        if cat.itemProtocol == 'zope':
            itms = cat.openList()
            for itm in itms:
                props = itm.properties
                # @@@ Gogo.
                if socket.gethostbyname(props['host']) == socket.gethostbyname(host) and \
                       props['httpport'] == port:
                    # @@@ original code follows:
                    # if props['host'].lower() == host.lower() and \
                    #       props['httpport'] == port:
                    path = '/'.join(filepaths)
                    name = itm.name or itm.treename
                    return 'zope', '%s|%s' %(name, meta), path, \
                           'zope://%s/<%s>/%s'%(name, meta, path)

    raise ExplorerNodes.TransportCategoryError(\
          'Could not map Zope debug path to defined Zope Category item',
          filepath)
Exemple #2
0
def uriSplitZope(filename, filepath):
    # zope://[category]/<[meta type]>/[path] format
    segs = filepath.split('/')
    if len(segs) < 2:
        raise ExplorerNodes.TransportCategoryError('Category not found',
                                                   filepath)
    category = segs[0] + '|' + segs[1][1:-1]
    return 'zope', category, '/'.join(segs[2:]), filename