Commit 2f30c2e9 authored by Ivan Tyagov's avatar Ivan Tyagov

Start another activity attemp only if counter allows it. Make it possible...

Start another activity attemp only if counter allows it. Make it possible configure repeat interval.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35730 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fbe474e8
...@@ -615,7 +615,7 @@ class ContributionTool(BaseTool): ...@@ -615,7 +615,7 @@ class ContributionTool(BaseTool):
content.setContentMd5(new_content_md5) content.setContentMd5(new_content_md5)
security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL') security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL')
def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, batch_mode=True, **kw): def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, repeat_interval=1, batch_mode=True, **kw):
""" """
A wrapper method for newContent which provides extra safety A wrapper method for newContent which provides extra safety
in case or errors (ie. download, access, conflict, etc.). in case or errors (ie. download, access, conflict, etc.).
...@@ -648,22 +648,25 @@ class ContributionTool(BaseTool): ...@@ -648,22 +648,25 @@ class ContributionTool(BaseTool):
# which had to add this url to bad URL list, so next time we avoid # which had to add this url to bad URL list, so next time we avoid
# crawling bad URL # crawling bad URL
raise raise
# Catch any HTTP error if repeat > 0:
self.activate(at_date=DateTime() + 1).newContentFromURL( # Catch any HTTP error
container_path=container_path, id=id, self.activate(at_date=DateTime() + repeat_interval).newContentFromURL(
repeat=repeat - 1, **kw) container_path=container_path, id=id,
repeat=repeat - 1,
repeat_interval=repeat_interval, **kw)
except urllib2.URLError, error: except urllib2.URLError, error:
if repeat == 0 and batch_mode: if repeat == 0 and batch_mode:
# XXX - Call the extendBadURLList method, --NOT Implemented-- # XXX - Call the extendBadURLList method, --NOT Implemented--
raise raise
print error.reason
#if getattr(error.reason,'args',None): #if getattr(error.reason,'args',None):
#if error.reason.args[0] == socket.EAI_AGAIN: #if error.reason.args[0] == socket.EAI_AGAIN:
## Temporary failure in name resolution - try again in 1 day ## Temporary failure in name resolution - try again in 1 day
self.activate(at_date=DateTime() + 1, if repeat > 0:
activity="SQLQueue").newContentFromURL( self.activate(at_date=DateTime() + repeat_interval,
container_path=container_path, id=id, activity="SQLQueue").newContentFromURL(
repeat=repeat - 1, **kw) container_path=container_path, id=id,
repeat=repeat - 1,
repeat_interval=repeat_interval, **kw)
return document return document
def _guessPortalType(self, name, typ, body): def _guessPortalType(self, name, typ, body):
......
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