Commit d31e55a3 authored by Bartek Górny's avatar Bartek Górny

reimplemented external status message as workflow variable

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12196 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c0f2ddf7
...@@ -127,20 +127,24 @@ class ExternalDocument(Document): ...@@ -127,20 +127,24 @@ class ExternalDocument(Document):
s,inf=self._spiderSource() s,inf=self._spiderSource()
except Exception,e: except Exception,e:
self.log(e,level=1) self.log(e,level=1)
self.setExternalProcessingStatusMessage("Tried on %s: %s" % (self._time(),str(e))) msg = "Tried on %s: %s" % (self._time(),str(e))
portal_workflow.doActionFor(context, 'process', comment=msg)
return False return False
chars=len(s) chars=len(s)
if chars==0: if chars==0:
self.setExternalProcessingStatusMessage("Tried on %s: got empty string" % self._time()) msg = "Tried on %s: got empty string" % self._time()
portal_workflow.doActionFor(context, 'process', comment=msg)
return False return False
try: try:
s=self._processData(s,inf) s=self._processData(s,inf)
except Exception,e: except Exception,e:
self.log(e,level=1) self.log(e,level=1)
self.setExternalProcessingStatusMessage("Spidered on %s, %i chars, but could not process; reason: %s" % (self._time(), chars, str(e))) msg = "Spidered on %s, %i chars, but could not process; reason: %s" % (self._time(), chars, str(e))
portal_workflow.doActionFor(context, 'process', comment=msg)
return False return False
self.setTextContent(s) self.setTextContent(s)
self.setExternalProcessingStatusMessage("Spidered on %s, %i chars, recorded %i chars" % (self._time(), chars, len(s))) msg = "Spidered on %s, %i chars, recorded %i chars" % (self._time(), chars, len(s))
portal_workflow.doActionFor(context, 'process', comment=msg)
return True return True
security.declareProtected(Permissions.View, 'getProtocolItemList') security.declareProtected(Permissions.View, 'getProtocolItemList')
......
...@@ -30,10 +30,13 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod ...@@ -30,10 +30,13 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.File import stripHtml from Products.ERP5.Document.File import stripHtml
from Products.ERP5.Document.ExternalDocument import ExternalDocument, SpiderException from Products.ERP5.Document.ExternalDocument import ExternalDocument, SpiderException
from Products.CMFCore.utils import getToolByName
import mimetypes, re, urllib import mimetypes, re, urllib
from htmlentitydefs import name2codepoint from htmlentitydefs import name2codepoint
portal_workflow = getToolByName('portal_workflow')
rx=[] rx=[]
rx.append(re.compile('<!--.*?-->',re.DOTALL|re.MULTILINE)) # clear comments (sometimes JavaScript code in comments contains > chars) rx.append(re.compile('<!--.*?-->',re.DOTALL|re.MULTILINE)) # clear comments (sometimes JavaScript code in comments contains > chars)
rx.append(re.compile('<[^>]*?>',re.DOTALL|re.MULTILINE)) # clear tags rx.append(re.compile('<[^>]*?>',re.DOTALL|re.MULTILINE)) # clear tags
...@@ -202,7 +205,8 @@ class ExternalWebPage(ExternalDocument): ...@@ -202,7 +205,8 @@ class ExternalWebPage(ExternalDocument):
try: try:
s=recode(s) s=recode(s)
except CanNotDecode: except CanNotDecode:
self.setExternalProcessingStatusMessage("Spidered on %s, %i chars, but could not decode" % (self._time(), chars)) msg = "Spidered on %s, %i chars, but could not decode" % (self._time(), chars)
portal_workflow.doActionFor(context, 'process', comment=msg)
return False return False
s=stripHtml(s) # remove headers, doctype and the like s=stripHtml(s) # remove headers, doctype and the like
s=clearHtml(s) # remove tags s=clearHtml(s) # remove tags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment