Esempio n. 1
0
 def __init__(self, term, label = None, scheme = None):
     self.term = term
     self.label = label
     self.scheme = scheme
     name = getNoneString(label)
     if not name:
         name = getSafeString(term)
     ZServerBlogCategory.__init__(self, term, name)
    def _populateServerEntry(self, zserverBlogEntry, zblog, zblogDocument,
                             zxhtmlDocument, zpubinfo):
        # Populate a ZServerBlogEntry given raven pubmeta data and post content.
        # Note: zpubinfo is valid only when updating existing post. It is None when posting new entry.
        pubmetadata = self._getPubMetaData(zblog, zblogDocument)
        title = zblogDocument.getTitle()
        content = self._transformContentForPublishing(zblog, zxhtmlDocument)

        zserverBlogEntry.setTitle(title)
        zserverBlogEntry.setContent(content)
        pubSchemaDT = pubmetadata.getPublishTime()

        # set pub time.
        if pubSchemaDT:
            # if user has specified a pub datetime, then use it.
            zserverBlogEntry.setUtcDateTime(
                pubSchemaDT.getDateTime())  # getDateTime
        elif zpubinfo:
            # if updating existing post, then use the previouslty published time
            publishedSchemaDt = zpubinfo.getPublishedTime()
            zserverBlogEntry.setUtcDateTime(publishedSchemaDt.getDateTime())
        else:
            # default to current time.
            nowDT = getCurrentUtcDateTime()
            zserverBlogEntry.setUtcDateTime(nowDT)

        zserverBlogEntry.setDraft(pubmetadata.isPublishAsDraft())
        for ravenCat in pubmetadata.getCategories():
            serverCatId = self._getServerId(ravenCat.getId())
            serverCat = ZServerBlogCategory(serverCatId, ravenCat.getName())
            self._copyAttrsFromRavenToServer(ravenCat, serverCat)
            zserverBlogEntry.addCategory(serverCat)

        # zblogDocument::getTagwordsList() -> list of ZTagwords (a ZTagwords is a list of words per site e.g. Technorati)
        listOfWords = getWordListFromZTagwords(zblogDocument.getTagwordsList())
        zserverBlogEntry.setTagwords(listOfWords)

        # custom meta data. (WP slug, password and post status
        slug = getCustomWPMetaDataAttribute(pubmetadata,
                                            u"wp_slug")  #$NON-NLS-1$
        if slug is not None:
            zserverBlogEntry.setAttribute(
                u"wp_slug", slug,
                IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$
        status = getNoneString(
            getCustomWPMetaDataAttribute(pubmetadata,
                                         u"post_status"))  #$NON-NLS-1$
        if status:
            zserverBlogEntry.setAttribute(
                u"post_status", status,
                IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$
        pw = getSafeString(
            getCustomWPMetaDataAttribute(pubmetadata,
                                         u"wp_password"))  #$NON-NLS-1$
        zserverBlogEntry.setAttribute(
            u"wp_password", pw,
            IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$

        return zserverBlogEntry
Esempio n. 3
0
 def __init__(self, id, name):
     ZServerBlogCategory.__init__(self, id, name)
Esempio n. 4
0
 def __init__(self, id, name):
     ZServerBlogCategory.__init__(self, id, name)