def setTrackbackUrlList(self, urlList): tbList = [] for url in urlList: trackback = ZTrackback() trackback.setUrl(url) tbList.append(trackback) self.setTrackbacks(tbList)
def _deserializeSentTrackbacks(self, pubInfoNode, pubInfo): nodes = pubInfoNode.selectNodes(u"zns:trackbackrefs/zns:trackbackref") #$NON-NLS-1$ for node in nodes: sentTrackback = ZTrackback() self._deserializeAttributes(node, sentTrackback) if getNoneString( sentTrackback.getUrl() ) and sentTrackback.isSent(): # 9/26/2007: Add only if url exists and tb has been sent. (url=None in docs imported from ZBW using build 0.8.109 or earlier. Ver 0.8.111 or later is OK) # (due to change of attr name from 'ping' to 'url'). Should not impact anyone since trackback support will be added ver 0.8.111+ pubInfo.addTrackback(sentTrackback)
def _deserializeSentTrackbacks(self, pubInfoNode, pubInfo): nodes = pubInfoNode.selectNodes( u"zns:trackbackrefs/zns:trackbackref") #$NON-NLS-1$ for node in nodes: sentTrackback = ZTrackback() self._deserializeAttributes(node, sentTrackback) if getNoneString( sentTrackback.getUrl()) and sentTrackback.isSent(): # 9/26/2007: Add only if url exists and tb has been sent. (url=None in docs imported from ZBW using build 0.8.109 or earlier. Ver 0.8.111 or later is OK) # (due to change of attr name from 'ping' to 'url'). Should not impact anyone since trackback support will be added ver 0.8.111+ pubInfo.addTrackback(sentTrackback)
def _sendTrackbacks(self, trackbackUrlList): blog = self._getContext().getBlog() blogName = getNoneString( blog.getName() ) id = blog.getUrl() title = self._getContext().getTitle() if blogName is None: blogName = title # get the post entry url. postUrl = getNoneString( self._getContext().getUrl() ) if not postUrl: pass #log error and return if not id: id = postUrl # post summary excerpt = self._getContext().getXhtmlDocument().getSummary(500) pinger = ZTrackbackPinger() sentCount = 0 for pingUrl in trackbackUrlList: if self.isCancelled(): return s = u"Sending trackback to %s" % pingUrl #$NON-NLS-1$ self._getContext().logInfo(self, s) self._getContext().notifyProgress(self, s, 1, False) ok = False msg = u"" #$NON-NLS-1$ try: response = pinger.ping(pingUrl, id, postUrl, title, blogName, excerpt) ok = response.isSuccessful() msg = getSafeString(response.getMessage()) except Exception, e: ok = False msg = unicode(e) if ok: trackback = ZTrackback() trackback.setUrl(pingUrl) #$NON-NLS-1$ trackback.setSentDate(ZSchemaDateTime()) pubInfo = self._getPubInfo() if pubInfo: pubInfo.addTrackback(trackback) sentCount = sentCount + 1 s = u"Trackback sent successfully: %s" % msg #$NON-NLS-1$ self._getContext().logInfo(self, s) self._getContext().notifyProgress(self, s, 0, False) else: s = u"Trackback failed: %s" % msg #$NON-NLS-1$ self._getContext().logError(self, s) self._getContext().notifyProgress(self, s, 0, False)
def _deserializeTrackbacks(self, documentDom, document): nodes = documentDom.selectNodes( u"/zns:entry/zns:trackbacks/zns:trackback") #$NON-NLS-1$ for node in nodes: trackback = ZTrackback() self._deserializeAttributes(node, trackback) document.addTrackback(trackback)
def _deserializePubMetadataTrackbacks(self, metaDataNode, pubMetaData): nodes = metaDataNode.selectNodes( u"zns:trackbackrefs/zns:trackbackref") #$NON-NLS-1$ for node in nodes: trackback = ZTrackback() self._deserializeAttributes(node, trackback) pubMetaData.addTrackback(trackback)
def _sendTrackbacks(self, trackbackUrlList): blog = self._getContext().getBlog() blogName = getNoneString(blog.getName()) id = blog.getUrl() title = self._getContext().getTitle() if blogName is None: blogName = title # get the post entry url. postUrl = getNoneString(self._getContext().getUrl()) if not postUrl: pass #log error and return if not id: id = postUrl # post summary excerpt = self._getContext().getXhtmlDocument().getSummary(500) pinger = ZTrackbackPinger() sentCount = 0 for pingUrl in trackbackUrlList: if self.isCancelled(): return s = u"Sending trackback to %s" % pingUrl #$NON-NLS-1$ self._getContext().logInfo(self, s) self._getContext().notifyProgress(self, s, 1, False) ok = False msg = u"" #$NON-NLS-1$ try: response = pinger.ping(pingUrl, id, postUrl, title, blogName, excerpt) ok = response.isSuccessful() msg = getSafeString(response.getMessage()) except Exception, e: ok = False msg = unicode(e) if ok: trackback = ZTrackback() trackback.setUrl(pingUrl) #$NON-NLS-1$ trackback.setSentDate(ZSchemaDateTime()) pubInfo = self._getPubInfo() if pubInfo: pubInfo.addTrackback(trackback) sentCount = sentCount + 1 s = u"Trackback sent successfully: %s" % msg #$NON-NLS-1$ self._getContext().logInfo(self, s) self._getContext().notifyProgress(self, s, 0, False) else: s = u"Trackback failed: %s" % msg #$NON-NLS-1$ self._getContext().logError(self, s) self._getContext().notifyProgress(self, s, 0, False)