Example #1
0
    def _load(self):
        if not self.registryFile or not os.path.exists(self.registryFile):
            return

        mediaStorageDir = os.path.basename(self.registryFile)

        dom = ZDom()
        dom.load(self.registryFile)
        # Legacy handling - old registry file format
        for fileElem in dom.selectNodes(u"/registry/file"):  #$NON-NLS-1$
            fileName = fileElem.getText()
            size = int(fileElem.getAttribute(u"size"))  #$NON-NLS-1$
            timestamp = ZSchemaDateTime(
                fileElem.getAttribute(u"timestamp"))  #$NON-NLS-1$
            url = fileElem.getAttribute(u"url")  #$NON-NLS-1$
            self.addFile(fileName, size, timestamp, url)
        # New registry file format
        for entryElem in dom.selectNodes(u"/registry/entry"):  #$NON-NLS-1$
            size = int(entryElem.getAttribute(u"size"))  #$NON-NLS-1$
            timestamp = ZSchemaDateTime(
                entryElem.getAttribute(u"timestamp"))  #$NON-NLS-1$
            relativeFileName = entryElem.selectSingleNodeText(
                u"file")  #$NON-NLS-1$
            fileName = resolveRelativePath(mediaStorageDir, relativeFileName)
            url = entryElem.selectSingleNodeText(u"url")  #$NON-NLS-1$
            embedFragment = entryElem.selectSingleNode(
                u"embed/*")  #$NON-NLS-1$
            metaData = entryElem.selectSingleNode(u"metaData/*")  #$NON-NLS-1$
            uploadResponse = ZUploadResponse(url, embedFragment, metaData)
            self.addFileEntry(fileName, size, timestamp, uploadResponse)
Example #2
0
    def _load(self):
        if not self.registryFile or not os.path.exists(self.registryFile):
            return

        mediaStorageDir = os.path.basename(self.registryFile)

        dom = ZDom()
        dom.load(self.registryFile)
        # Legacy handling - old registry file format
        for fileElem in dom.selectNodes(u"/registry/file"): #$NON-NLS-1$
            fileName = fileElem.getText()
            size = int(fileElem.getAttribute(u"size")) #$NON-NLS-1$
            timestamp = ZSchemaDateTime(fileElem.getAttribute(u"timestamp")) #$NON-NLS-1$
            url = fileElem.getAttribute(u"url") #$NON-NLS-1$
            self.addFile(fileName, size, timestamp, url)
        # New registry file format
        for entryElem in dom.selectNodes(u"/registry/entry"): #$NON-NLS-1$
            size = int(entryElem.getAttribute(u"size")) #$NON-NLS-1$
            timestamp = ZSchemaDateTime(entryElem.getAttribute(u"timestamp")) #$NON-NLS-1$
            relativeFileName = entryElem.selectSingleNodeText(u"file") #$NON-NLS-1$
            fileName = resolveRelativePath(mediaStorageDir, relativeFileName)
            url = entryElem.selectSingleNodeText(u"url") #$NON-NLS-1$
            embedFragment = entryElem.selectSingleNode(u"embed/*") #$NON-NLS-1$
            metaData = entryElem.selectSingleNode(u"metaData/*") #$NON-NLS-1$
            uploadResponse = ZUploadResponse(url, embedFragment, metaData)
            self.addFileEntry(fileName, size, timestamp, uploadResponse)
Example #3
0
 def _convertUri(self, uri):
     magicNum = len(IZDocumentSerializationConstants.RAVEN_BLOG_DOCUMENT_PATH_TOKEN) + 1
     relativePath = uri[magicNum:]
     if relativePath:
         resolvedPath = resolveRelativePath(self.dataDir, relativePath)
         return encodeUri(resolvedPath)
     return None
Example #4
0
 def _convertUri(self, uri):
     magicNum = len(IZDocumentSerializationConstants.
                    RAVEN_BLOG_DOCUMENT_PATH_TOKEN) + 1
     relativePath = uri[magicNum:]
     if relativePath:
         resolvedPath = resolveRelativePath(self.dataDir, relativePath)
         return encodeUri(resolvedPath)
     return None
Example #5
0
 def getProfile(self, profileName):
     profileElem = self.profilesDom.selectSingleNode(u"/profiles/profile[@name = \"%s\"]" % profileName) #$NON-NLS-1$
     if profileElem is not None:
         profileModel = ZProfileModel(profileElem)
         path = profileModel.getPath()
         profilesDir = self.getDefaultProfilesDirectory()
         resolvedPath = resolveRelativePath(profilesDir, path)
         profileModel.setPath(resolvedPath)
         return profileModel
     return None
Example #6
0
 def getProfile(self, profileName):
     profileElem = self.profilesDom.selectSingleNode(
         u"/profiles/profile[@name = \"%s\"]" % profileName)  #$NON-NLS-1$
     if profileElem is not None:
         profileModel = ZProfileModel(profileElem)
         path = profileModel.getPath()
         profilesDir = self.getDefaultProfilesDirectory()
         resolvedPath = resolveRelativePath(profilesDir, path)
         profileModel.setPath(resolvedPath)
         return profileModel
     return None
Example #7
0
 def getResolvedRootFile(self):
     return resolveRelativePath(self.getTemplateDirectory(), self.getRootFileName())
Example #8
0
 def getResolvedRootFile(self):
     return resolveRelativePath(self.getTemplateDirectory(),
                                self.getRootFileName())