[Erp5-report] r42006 kazuhiko - in /erp5/trunk/products/ERP5: Document/ Tool/ interfaces/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jan 4 17:53:40 CET 2011


Author: kazuhiko
Date: Tue Jan  4 17:53:40 2011
New Revision: 42006

URL: http://svn.erp5.org?rev=42006&view=rev
Log:
* add repeat_interval and batch_mode argument just same as newContentFromURL().
* remove needless duplicate code.

Modified:
    erp5/trunk/products/ERP5/Document/Document.py
    erp5/trunk/products/ERP5/Tool/ContributionTool.py
    erp5/trunk/products/ERP5/interfaces/uploadable.py

Modified: erp5/trunk/products/ERP5/Document/Document.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Document.py?rev=42006&r1=42005&r2=42006&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Document.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Document.py [utf8] Tue Jan  4 17:53:40 2011
@@ -758,7 +758,8 @@ class Document(DocumentExtensibleTravers
     if method is not None: method()
 
   security.declareProtected(Permissions.ModifyPortalContent, 'updateContentFromURL')
-  def updateContentFromURL(self, repeat=MAX_REPEAT, crawling_depth=0):
+  def updateContentFromURL(self, repeat=MAX_REPEAT, crawling_depth=0,
+                           repeat_interval=1, batch_mode=True):
     """
       Download and update content of this document from its source URL.
       Implementation is handled by ContributionTool.

Modified: erp5/trunk/products/ERP5/Tool/ContributionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/ContributionTool.py?rev=42006&r1=42005&r2=42006&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] Tue Jan  4 17:53:40 2011
@@ -541,7 +541,8 @@ class ContributionTool(BaseTool):
       url_registry_tool.registerURL(url, None, context=container)
 
   security.declareProtected(Permissions.AddPortalContent, 'updateContentFromURL')
-  def updateContentFromURL(self, content, repeat=MAX_REPEAT, crawling_depth=0):
+  def updateContentFromURL(self, content, repeat=MAX_REPEAT, crawling_depth=0,
+                           repeat_interval=1, batch_mode=True):
     """
       Updates an existing content.
     """
@@ -555,20 +556,11 @@ class ContributionTool(BaseTool):
       try:
         url = content.asURL()
         file_object, filename, content_type = self._openURL(url)
-      except urllib2.HTTPError, error:
-        if repeat == 0:
-          # XXX - Call the extendBadURLList method,--NOT Implemented--
-          # IDEA : ajouter l'url en question dans une list "bad_url_list" puis lors du crawling au lieu que de boucler sur 
-          #        la liste des url extraites de la page web on fait un test supplementaire qui verifie que l'url n'est pas 
-          #        dans la liste bad_url_lis
-          raise
-        content.activate(at_date=DateTime() + 1).updateContentFromURL(repeat=repeat - 1)
-        return
       except urllib2.URLError, error:
-        if repeat == 0:
+        if repeat == 0 or not batch_mode:
           # XXX - Call the extendBadURLList method,--NOT Implemented--
           raise
-        content.activate(at_date=DateTime() + 1).updateContentFromURL(repeat=repeat - 1)
+        content.activate(at_date=DateTime() + repeat_interval).updateContentFromURL(repeat=repeat - 1)
         return
 
       content._edit(file=file_object, content_type=content_type)

Modified: erp5/trunk/products/ERP5/interfaces/uploadable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/uploadable.py?rev=42006&r1=42005&r2=42006&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/uploadable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/interfaces/uploadable.py [utf8] Tue Jan  4 17:53:40 2011
@@ -94,7 +94,8 @@ class IUploadable(Interface):
     passed to IConvertable.convert or to IDownloadable.index_html
     """
 
-  def updateContentFromURL(url=None, repeat=MAX_REPEAT, crawling_depth=0):
+  def updateContentFromURL(url=None, repeat=MAX_REPEAT, crawling_depth=0,
+                           repeat_interval=1, batch_mode=True):
     """
     Download and update content of this document from the specified URL.
     If no url is specified, Document which support the IUrlGetter
@@ -103,11 +104,15 @@ class IUploadable(Interface):
     url -- optional URL to download the updated content from.
            required whenever document does not implement IUrlGetter
 
-    repeat -- optional max number of retries for download
-
     crawling_depth -- optional crawling depth for documents which 
                       implement ICrawlable
 
+    repeat -- optional max number of retries for download
+
+    repeat_interval -- optional interval between repeats
+
+    batch_mode -- optional specify False if used in a user interface
+
     NOTE: implementation is normally delegated to ContributionTool.
 
     XXX - it is unclear whether MAX_REPEAT should be part of signature



More information about the Erp5-report mailing list