def setPubMetaData(self, pubMetaData): # Updates the UI controls based on the data in pubMetaData self.draftCB.SetValue(pubMetaData.isPublishAsDraft()) pubTime = pubMetaData.getPublishTime() if pubTime is not None: self.overridePubTimeCB.SetValue(True) self.dateCtrl.Enable(True) self.dateCtrl.setDateTime(pubTime) self.thumbnailsOnlyCB.SetValue(pubMetaData.isUploadTNsOnly()) self.forceUploadCB.SetValue(pubMetaData.isForceReUploadImages()) self.lightboxCB.SetValue(pubMetaData.isAddLightbox()) self.poweredByZoundryCB.SetValue(pubMetaData.isAddPoweredBy()) # WP custom data slug = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_slug") ) #$NON-NLS-1$ self.wpPostSlugTextCtrl.SetValue(slug) # WP password s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_password") ) #$NON-NLS-1$ self.wpPasswordTextCtrl.SetValue(s) # WP pub status self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"post_status") ) #$NON-NLS-1$ if s == u"pending": #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_PENDING elif s == u"private": #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_PRIVATE elif s == u"draft" or pubMetaData.isPublishAsDraft(): #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_DRAFT self.wpPubStatusCombo.SetSelection(self.wpPublishStatusValue)
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 setPubMetaData(self, pubMetaData): # Updates the UI controls based on the data in pubMetaData self.draftCB.SetValue(pubMetaData.isPublishAsDraft()) pubTime = pubMetaData.getPublishTime() if pubTime is not None: self.overridePubTimeCB.SetValue(True) self.dateCtrl.Enable(True) self.dateCtrl.setDateTime(pubTime) self.thumbnailsOnlyCB.SetValue(pubMetaData.isUploadTNsOnly()) self.forceUploadCB.SetValue(pubMetaData.isForceReUploadImages()) self.lightboxCB.SetValue(pubMetaData.isAddLightbox()) self.poweredByZoundryCB.SetValue(pubMetaData.isAddPoweredBy()) # WP custom data slug = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_slug")) #$NON-NLS-1$ self.wpPostSlugTextCtrl.SetValue(slug) # WP password s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_password")) #$NON-NLS-1$ self.wpPasswordTextCtrl.SetValue(s) # WP pub status self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"post_status")) #$NON-NLS-1$ if s == u"pending": #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_PENDING elif s == u"private": #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_PRIVATE elif s == u"draft" or pubMetaData.isPublishAsDraft(): #$NON-NLS-1$ self.wpPublishStatusValue = ZPubMetaDataView.WP_DRAFT self.wpPubStatusCombo.SetSelection(self.wpPublishStatusValue)