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
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) # ---- # print "DEBUG (blogpublisher:_populateServerEntry): ", content # DEBUG: ChuahTC 2013-Sep-2 # ---- 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
def _getWordList(self): # get list of IZTagwords izTagwordsList = self._getContext().getTagwordList() # extract a string list from the list of IZTagwords listOfWords = getWordListFromZTagwords(izTagwordsList) return listOfWords