Ejemplo n.º 1
0
    def _deserializeContent(self, documentDom, document, deserializationContext):
        contentNode = documentDom.selectSingleNode(u"/zns:entry/zns:content") #$NON-NLS-1$

        # Handle the Case of the Missing Content
        if not contentNode:
            xhtmlDoc = loadXhtmlDocumentFromString(u"") #$NON-NLS-1$
            content = ZXhtmlContent()
            content.setMode(u"xml") #$NON-NLS-1$
            content.setType(u"application/xhtml+xml") #$NON-NLS-1$
            content.setXhtmlDocument(xhtmlDoc)
            document.setContent(content)
            return

        self._processContent(contentNode, deserializationContext)

        mode = contentNode.getAttribute(u"mode") #$NON-NLS-1$
        type = contentNode.getAttribute(u"type") #$NON-NLS-1$

        content = ZXhtmlContent()
        content.setMode(mode)
        content.setType(type)

        if mode == u"xml": #$NON-NLS-1$
            xhtmlNode = contentNode.selectSingleNode(u"*") #$NON-NLS-1$
            xhtmlDoc = loadXhtmlDocumentFromDOM(xhtmlNode)
            content.setXhtmlDocument(xhtmlDoc)
        elif mode == u"escaped": #$NON-NLS-1$
            htmlText = contentNode.getText()
            xhtmlDoc = loadXhtmlDocumentFromString(htmlText)
            content.setXhtmlDocument(xhtmlDoc)
        else:
            raise ZBlogAppException(_extstr(u"deserializers.NoContentModeFoundError")) #$NON-NLS-1$

        document.setContent(content)
Ejemplo n.º 2
0
 def _handleFileList(self, fileList):
     if not fileList:
         return None
     rootEle = None
     if len(fileList) == 1:
         rootEle = self._createFileAnchorElement(fileList[0], None)
     else:
         rootEle = createHtmlElement(None, u"p")  #$NON-NLS-1$
         for fileName in fileList:
             self._createFileAnchorElement(fileName, rootEle)
             createHtmlElement(rootEle, u"br")  #$NON-NLS-1$
     xhtmlDom = loadXhtmlDocumentFromDOM(rootEle)
     return xhtmlDom
Ejemplo n.º 3
0
 def _handleFileList(self, fileList):
     if not fileList:
         return None
     rootEle = None
     if len(fileList) == 1:
         rootEle = self._createFileAnchorElement(fileList[0], None)
     else:
         rootEle = createHtmlElement(None, u"p") #$NON-NLS-1$
         for fileName in fileList:
             self._createFileAnchorElement(fileName, rootEle)
             createHtmlElement(rootEle, u"br") #$NON-NLS-1$
     xhtmlDom = loadXhtmlDocumentFromDOM(rootEle)
     return xhtmlDom
Ejemplo n.º 4
0
    def _deserializeContent(self, documentDom, document,
                            deserializationContext):
        contentNode = documentDom.selectSingleNode(
            u"/zns:entry/zns:content")  #$NON-NLS-1$

        # Handle the Case of the Missing Content
        if not contentNode:
            xhtmlDoc = loadXhtmlDocumentFromString(u"")  #$NON-NLS-1$
            content = ZXhtmlContent()
            content.setMode(u"xml")  #$NON-NLS-1$
            content.setType(u"application/xhtml+xml")  #$NON-NLS-1$
            content.setXhtmlDocument(xhtmlDoc)
            document.setContent(content)
            return

        self._processContent(contentNode, deserializationContext)

        mode = contentNode.getAttribute(u"mode")  #$NON-NLS-1$
        type = contentNode.getAttribute(u"type")  #$NON-NLS-1$

        content = ZXhtmlContent()
        content.setMode(mode)
        content.setType(type)

        if mode == u"xml":  #$NON-NLS-1$
            xhtmlNode = contentNode.selectSingleNode(u"*")  #$NON-NLS-1$
            xhtmlDoc = loadXhtmlDocumentFromDOM(xhtmlNode)
            content.setXhtmlDocument(xhtmlDoc)
        elif mode == u"escaped":  #$NON-NLS-1$
            htmlText = contentNode.getText()
            xhtmlDoc = loadXhtmlDocumentFromString(htmlText)
            content.setXhtmlDocument(xhtmlDoc)
        else:
            raise ZBlogAppException(
                _extstr(
                    u"deserializers.NoContentModeFoundError"))  #$NON-NLS-1$

        document.setContent(content)