Example #1
0
    def clientFNToServerFN(self, filename):
        """Converts a filename on the client to a filename on the server.

        Currently just turns file URLs into paths.  If you want to be able to
        set breakpoints when running the client in a different environment
        from the server, you'll need to expand this.
        """
        # XXX should we .fncache this? Files changing names are undefined
        # XXX during the lifetime of the debugger

        from Explorers.Explorer import splitURI, getTransport
        from Explorers.ExplorerNodes import all_transports

        prot, category, filepath, filename = splitURI(filename)
        if prot == 'zope':
            node = getTransport(prot, category, filepath, all_transports)
            if node:
                props = node.properties
                return 'zopedebug://%s:%s/%s/%s' % (
                    props['host'], props['httpport'], filepath, node.metatype)
            else:
                raise Exception(_('No Zope connection for: %s') % filename)
        elif prot == 'zopedebug':
            raise Exception(_('"zopedebug" is a server filename protocol'))
        else:
            #if prot == 'file':
            if self.serverClientPaths:
                normFilepath = os.path.normcase(filepath)
                for serverPath, clientPath in self.serverClientPaths:
                    normClientPath = os.path.normcase(clientPath)
                    if normFilepath.startswith(normClientPath):
                        return serverPath + normFilepath[len(normClientPath):]
            return filepath
Example #2
0
    def clientFNToServerFN(self, filename):
        """Converts a filename on the client to a filename on the server.

        Currently just turns file URLs into paths.  If you want to be able to
        set breakpoints when running the client in a different environment
        from the server, you'll need to expand this.
        """
        # XXX should we .fncache this? Files changing names are undefined
        # XXX during the lifetime of the debugger

        from Explorers.Explorer import splitURI, getTransport
        from Explorers.ExplorerNodes import all_transports

        prot, category, filepath, filename = splitURI(filename)
        if prot == 'zope':
            node = getTransport(prot, category, filepath, all_transports)
            if node:
                props = node.properties
                return 'zopedebug://%s:%s/%s/%s'%(props['host'],
                      props['httpport'], filepath, node.metatype)
            else:
                raise Exception(_('No Zope connection for: %s')%filename)
        elif prot == 'zopedebug':
            raise Exception(_('"zopedebug" is a server filename protocol'))
        else:
        #if prot == 'file':
            if self.serverClientPaths:
                normFilepath = os.path.normcase(filepath)
                for serverPath, clientPath in self.serverClientPaths:
                    normClientPath = os.path.normcase(clientPath)
                    if normFilepath.startswith(normClientPath):
                        return serverPath+normFilepath[len(normClientPath):]
            return filepath
Example #3
0
    def serverFNToClientFN(self, filename):
        """Converts a filename on the server to a filename on the client.

        Currently just generates URLs.  If you want to be able to
        set breakpoints when running the client in a different environment
        from the server, you'll need to expand this.
        """
        from Explorers.Explorer import splitURI
        if self.serverClientPaths:
            normFilepath = os.path.normcase(filename)
            for serverPath, clientPath in self.serverClientPaths:
                normServerPath = os.path.normcase(serverPath)
                if normFilepath.startswith(normServerPath):
                    return splitURI(clientPath+normFilepath[len(normServerPath):])[3]

        return splitURI(filename)[3]
Example #4
0
    def serverFNToClientFN(self, filename):
        """Converts a filename on the server to a filename on the client.

        Currently just generates URLs.  If you want to be able to
        set breakpoints when running the client in a different environment
        from the server, you'll need to expand this.
        """
        from Explorers.Explorer import splitURI
        if self.serverClientPaths:
            normFilepath = os.path.normcase(filename)
            for serverPath, clientPath in self.serverClientPaths:
                normServerPath = os.path.normcase(serverPath)
                if normFilepath.startswith(normServerPath):
                    return splitURI(clientPath +
                                    normFilepath[len(normServerPath):])[3]

        return splitURI(filename)[3]
Example #5
0
 def createChildNode(self, fullpath):
     from Explorers.Explorer import splitURI, getTransport, TransportError
     prot, cat, res, uri = splitURI(fullpath)
     try:
         node = getTransport(prot, cat, res, self.catTransports)
     except TransportError:
         return None
     node.name = node.treename = fullpath
     return node
Example #6
0
    def assertLocalFile(self, filename=None):
        # XXX depreciated (and silly!)

        if filename is None:
            filename = self.filename
        from Explorers.Explorer import splitURI
        prot, cat, filename, uri = splitURI(filename)
        assert prot == 'file', _('Operation only supported on the filesystem.')
        return filename
 def createChildNode(self, fullpath):
     from Explorers.Explorer import splitURI, getTransport, TransportError
     prot, cat, res, uri = splitURI(fullpath)
     try:
         node = getTransport(prot, cat, res, self.catTransports)
     except TransportError:
         return None
     node.name = node.treename = fullpath
     return node
    def checkLocalFile(self, filename=None):
        """ Either return the model's uri as a local filepath or raise an error """

        if filename is None:
            filename = self.filename
        from Explorers.Explorer import splitURI, TransportError
        prot, cat, filename, uri = splitURI(filename)
        if prot != 'file':
            raise TransportError, _('Operation only supported on the filesystem.')
        return filename
Example #9
0
    def assertLocalFile(self, filename=None):
        # XXX depreciated (and silly!)

        if filename is None:
            filename = self.filename
        from Explorers.Explorer import splitURI

        prot, cat, filename, uri = splitURI(filename)
        assert prot == "file", _("Operation only supported on the filesystem.")
        return filename
Example #10
0
    def checkLocalFile(self, filename=None):
        """ Either return the model's uri as a local filepath or raise an error """

        if filename is None:
            filename = self.filename
        from Explorers.Explorer import splitURI, TransportError

        prot, cat, filename, uri = splitURI(filename)
        if prot != "file":
            raise TransportError, _("Operation only supported on the filesystem.")
        return filename
    def saveAs(self, filename):
        """ Saves contents of data to file specified by filename.
            Override this to catch name changes. """
        # Catch transport changes
        from Explorers.Explorer import splitURI, getTransport
        protO, catO, resO, uriO = splitURI(self.filename)
        protN, catN, resN, uriN = splitURI(filename)

        if protO != protN:
            self.transport = getTransport(protN, catN, resN,
                  self.editor.explorerStore.transports)#explorer.tree.transports)

        # Rename and save
        oldname = self.filename
        self.filename = filename
        try:
            self.save(overwriteNewer=True)
        except:
            self.filename = oldname
            raise
        self.savedAs = True
Example #12
0
    def saveAs(self, filename):
        """ Saves contents of data to file specified by filename.
            Override this to catch name changes. """
        # Catch transport changes
        from Explorers.Explorer import splitURI, getTransport

        protO, catO, resO, uriO = splitURI(self.filename)
        protN, catN, resN, uriN = splitURI(filename)

        if protO != protN:
            self.transport = getTransport(
                protN, catN, resN, self.editor.explorerStore.transports
            )  # explorer.tree.transports)

        # Rename and save
        oldname = self.filename
        self.filename = filename
        try:
            self.save(overwriteNewer=True)
        except:
            self.filename = oldname
            raise
        self.savedAs = True
    def idModel(self, name, src=None):
        # XXX This should be cached until rename or delete
        absPath = self.normaliseModuleRelativeToApp(self.modules[name][2])
        import Controllers

        from Explorers.Explorer import splitURI
        prot, cat, res, fn = splitURI(absPath)

        if src is None:
            if self.editor.modules.has_key(name):
                self.moduleModels[name], main = identifySource(
                    self.editor.modules[name].model.getDataAsLines())
            if self.editor.modules.has_key(absPath):
                self.moduleModels[name], main = identifySource(
                    self.editor.modules[absPath].model.getDataAsLines())
            else:
                try: self.moduleModels[name], main = \
                           Controllers.identifyFile(res, localfs=prot=='file')
                except: pass
        else:
            self.moduleModels[name], main = identifySource(src)
    def idModel(self, name, src=None):
        # XXX This should be cached until rename or delete
        absPath = self.normaliseModuleRelativeToApp(self.modules[name][2])
        import Controllers

        from Explorers.Explorer import splitURI
        prot, cat, res, fn = splitURI(absPath)

        if src is None:
            if self.editor.modules.has_key(name):
                self.moduleModels[name], main = identifySource(
                    self.editor.modules[name].model.getDataAsLines())
            if self.editor.modules.has_key(absPath):
                self.moduleModels[name], main = identifySource(
                    self.editor.modules[absPath].model.getDataAsLines())
            else:
                try: self.moduleModels[name], main = \
                           Controllers.identifyFile(res, localfs=prot=='file')
                except: pass
        else:
            self.moduleModels[name], main = identifySource(src)
    def createChildNode(self, name, value):
        if type(value) == type({}):
            return SubBookmarksCatNode(self, name, value)
        else:
            from Explorers.Explorer import splitURI, getTransport, TransportError
            prot, cat, res, uri = splitURI(value)
            try:
                node = getTransport(prot, cat, res, self.catTransports)
            except TransportError:
                # XXX should return broken link items
                #print 'transport not found %s %s %s' %(prot, cat, res)
                return None
            if node.isFolderish():
                if prot == 'file':
                    node.imgIdx = EditorHelper.imgFSDrive
                elif prot == 'zope':
                    node.imgIdx = EditorHelper.imgZopeConnection
                else:
                    node.imgIdx = EditorHelper.imgNetDrive

            node.treename = name
            return node
Example #16
0
    def createChildNode(self, name, value):
        if type(value) == type({}):
            return SubBookmarksCatNode(self, name, value)
        else:
            from Explorers.Explorer import splitURI, getTransport, TransportError
            prot, cat, res, uri = splitURI(value)
            try:
                node = getTransport(prot, cat, res, self.catTransports)
            except TransportError:
                # XXX should return broken link items
                #print 'transport not found %s %s %s' %(prot, cat, res)
                return None
            if node.isFolderish():
                if prot == 'file':
                    node.imgIdx = EditorHelper.imgFSDrive
                elif prot == 'zope':
                    node.imgIdx = EditorHelper.imgZopeConnection
                else:
                    node.imgIdx = EditorHelper.imgNetDrive

            node.treename = name
            return node
Example #17
0
 def assertFilename(self, filename):
     """ Utility function to strip and assert the protocol from the uri """
     from Explorers.Explorer import splitURI
     prot, cat, res, uri = splitURI(filename)
     assert self.protocol == prot, _('Illegal protocol change')
     return res
 def assertFilename(self, filename):
     """ Utility function to strip and assert the protocol from the uri """
     from Explorers.Explorer import splitURI
     prot, cat, res, uri = splitURI(filename)
     assert self.protocol==prot, _('Illegal protocol change')
     return res
Example #19
0
    def localFilename(self, filename=None):
        if filename is None:
            filename = self.filename
        from Explorers.Explorer import splitURI

        return splitURI(filename)[2]
Example #20
0
 def localFilename(self, filename=None):
     if filename is None: filename = self.filename
     from Explorers.Explorer import splitURI
     return splitURI(filename)[2]