From 5ec7fc53265498195bed73b65e0baa7bd4786b8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl>
Date: Mon, 22 Jan 2007 14:23:26 +0000
Subject: [PATCH] fixed workflow status implementation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12199 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/ExternalDocument.py | 6 +++++-
 product/ERP5/Document/ExternalWebPage.py  | 3 +--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Document/ExternalDocument.py b/product/ERP5/Document/ExternalDocument.py
index 4338e5e114..9606924875 100644
--- a/product/ERP5/Document/ExternalDocument.py
+++ b/product/ERP5/Document/ExternalDocument.py
@@ -29,8 +29,11 @@ from AccessControl import ClassSecurityInfo
 from Products.CMFCore.WorkflowCore import WorkflowMethod
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
 from Products.ERP5.Document.Document import Document
+from Products.CMFCore.utils import getToolByName
 
-import mimetypes, re, urllib
+import mimetypes
+import re
+import urllib
 from htmlentitydefs import name2codepoint
 from DateTime import DateTime
 
@@ -123,6 +126,7 @@ class ExternalDocument(Document):
     sets status message
     returned value tells us if it succeeded or failed
     """
+    portal_workflow = getToolByName(self, 'portal_workflow')
     try:
       s,inf=self._spiderSource()
     except Exception,e:
diff --git a/product/ERP5/Document/ExternalWebPage.py b/product/ERP5/Document/ExternalWebPage.py
index c873eb8ba2..22df7af486 100644
--- a/product/ERP5/Document/ExternalWebPage.py
+++ b/product/ERP5/Document/ExternalWebPage.py
@@ -35,8 +35,6 @@ from Products.CMFCore.utils import getToolByName
 import mimetypes, re, urllib
 from htmlentitydefs import name2codepoint
 
-portal_workflow = getToolByName('portal_workflow')
-
 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 tags
@@ -206,6 +204,7 @@ class ExternalWebPage(ExternalDocument):
       s=recode(s)
     except CanNotDecode:
       msg = "Spidered on %s, %i chars, but could not decode" % (self._time(), chars)
+      portal_workflow = getToolByName(self, 'portal_workflow')
       portal_workflow.doActionFor(context, 'process', comment=msg)
       return False
     s=stripHtml(s) # remove headers, doctype and the like
-- 
2.30.9