Exemplo n.º 1
0
 def setTrackbackUrlList(self, urlList):
     tbList = []
     for url in urlList:
         trackback = ZTrackback()
         trackback.setUrl(url)
         tbList.append(trackback)
     self.setTrackbacks(tbList)
Exemplo n.º 2
0
 def setTrackbackUrlList(self, urlList):
     tbList = []
     for url in urlList:
         trackback = ZTrackback()
         trackback.setUrl(url)
         tbList.append(trackback)
     self.setTrackbacks(tbList)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)