Commit 094c29fa authored by Ivan Tyagov's avatar Ivan Tyagov

url argument is mandatory so specify it accordingly in API. If an URL is...

url argument is mandatory so specify it accordingly in API. If an URL is NotFound and no need to repeat or batch mode return None, this will indicate that a document can not be created (this way we provide mentioned safety wrapper and let UI handle such cases accordingly rather than raise)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43510 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 18942e1c
...@@ -583,8 +583,8 @@ class ContributionTool(BaseTool): ...@@ -583,8 +583,8 @@ class ContributionTool(BaseTool):
content.activate().crawlContent() content.activate().crawlContent()
security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL') security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL')
def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, def newContentFromURL(self, url, container_path=None, id=None, repeat=MAX_REPEAT,
repeat_interval=1, batch_mode=True, url=None, **kw): 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.).
...@@ -597,8 +597,6 @@ class ContributionTool(BaseTool): ...@@ -597,8 +597,6 @@ class ContributionTool(BaseTool):
id parameter is ignored id parameter is ignored
""" """
document = None document = None
if not url:
raise TypeError, 'url parameter is mandatory'
try: try:
document = self.newContent(container_path=container_path, url=url, **kw) document = self.newContent(container_path=container_path, url=url, **kw)
if document.isIndexContent() and document.getCrawlingDepth() >= 0: if document.isIndexContent() and document.getCrawlingDepth() >= 0:
...@@ -608,11 +606,11 @@ class ContributionTool(BaseTool): ...@@ -608,11 +606,11 @@ class ContributionTool(BaseTool):
# If this is an index document, stop crawling if crawling_depth is 0 # If this is an index document, stop crawling if crawling_depth is 0
document.activate().crawlContent() document.activate().crawlContent()
except urllib2.HTTPError, error: except urllib2.HTTPError, error:
if repeat == 0 or not batch_mode: if (repeat == 0 or not batch_mode) and (error.getcode() == 404):
# here we must call the extendBadURLList method,--NOT Implemented-- # here we must call the extendBadURLList method,--NOT Implemented--
# 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 return None
if repeat > 0: if repeat > 0:
# Catch any HTTP error # Catch any HTTP error
self.activate(at_date=DateTime() + repeat_interval, self.activate(at_date=DateTime() + repeat_interval,
......
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