[Erp5-report] r43510 ivan - /erp5/trunk/products/ERP5/Tool/ContributionTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Feb 21 10:54:49 CET 2011


Author: ivan
Date: Mon Feb 21 10:54:49 2011
New Revision: 43510

URL: http://svn.erp5.org?rev=43510&view=rev
Log:
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)

Modified:
    erp5/trunk/products/ERP5/Tool/ContributionTool.py

Modified: erp5/trunk/products/ERP5/Tool/ContributionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/ContributionTool.py?rev=43510&r1=43509&r2=43510&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] Mon Feb 21 10:54:49 2011
@@ -583,8 +583,8 @@ class ContributionTool(BaseTool):
         content.activate().crawlContent()
 
   security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL')
-  def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT,
-                        repeat_interval=1, batch_mode=True, url=None, **kw):
+  def newContentFromURL(self, url, container_path=None, id=None, repeat=MAX_REPEAT,
+                        repeat_interval=1, batch_mode=True, **kw):
     """
       A wrapper method for newContent which provides extra safety
       in case or errors (ie. download, access, conflict, etc.).
@@ -597,8 +597,6 @@ class ContributionTool(BaseTool):
       id parameter is ignored
     """
     document = None
-    if not url:
-      raise TypeError, 'url parameter is mandatory'
     try:
       document = self.newContent(container_path=container_path, url=url, **kw)
       if document.isIndexContent() and document.getCrawlingDepth() >= 0:
@@ -608,11 +606,11 @@ 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 or not batch_mode:
+      if (repeat == 0 or not batch_mode) and (error.getcode() == 404):
         # 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
-        raise
+        return None
       if repeat > 0:
         # Catch any HTTP error
         self.activate(at_date=DateTime() + repeat_interval,



More information about the Erp5-report mailing list