Commit 63ae50df authored by Ivan Tyagov's avatar Ivan Tyagov

Extend API so we can control if exceptions are raises (in UI mode we need a...

Extend API so we can control if exceptions are raises (in UI mode we need a way without catching exceptions in ZODB scripts to detect and inform user that there's a problem with his URL)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35725 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f99c36c9
......@@ -615,7 +615,7 @@ class ContributionTool(BaseTool):
content.setContentMd5(new_content_md5)
security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL')
def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, **kw):
def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, batch_mode=True, **kw):
"""
A wrapper method for newContent which provides extra safety
in case or errors (ie. download, access, conflict, etc.).
......@@ -643,7 +643,7 @@ class ContributionTool(BaseTool):
# If this is an index document, stop crawling if crawling_depth is 0
document.activate().crawlContent()
except urllib2.HTTPError, error:
if repeat == 0:
if repeat == 0 and batch_mode:
# here we must call the extendBadURLList method,--NOT Implemented--
# which had to add this url to bad URL list, so next time we avoid
# crawling bad URL
......@@ -653,7 +653,7 @@ class ContributionTool(BaseTool):
container_path=container_path, id=id,
repeat=repeat - 1, **kw)
except urllib2.URLError, error:
if repeat == 0:
if repeat == 0 and batch_mode:
# XXX - Call the extendBadURLList method, --NOT Implemented--
raise
print error.reason
......
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