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

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Mar 18 19:03:14 CET 2007


Author: jp
Date: Sun Mar 18 19:03:13 2007
New Revision: 13482

URL: http://svn.erp5.org?rev=13482&view=rev
Log:
Implemented MixIn which supports URL encoding and decoding.

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=13482&r1=13481&r2=13482&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/ContributionTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/ContributionTool.py Sun Mar 18 19:03:13 2007
@@ -122,7 +122,7 @@
     return portal_type
 
   security.declareProtected(Permissions.AddPortalContent, 'newContent')
-  def newContent(self, id=None, portal_type=None, url=None,
+  def newContent(self, id=None, portal_type=None, url=None, container=None,
                        discover_metadata=1, temp_object=0,
                        user_login=None, **kw):
     """
@@ -134,6 +134,12 @@
       user_login is the name under which the content will be created
       XXX - this is a security hole which needs to be fixed by
       making sure only Manager can use this parameter
+
+      container -- if specified, it is possible to define
+      where to contribute the content. Else, ContributionTool
+      tries to guess.
+
+      url -- if specified, content is download from the URL.
 
       NOTE:
         We always generate ID. So, we must prevent using the one
@@ -216,7 +222,7 @@
     BaseTool._delObject(self, file_name)
 
     # Move the document to where it belongs
-    document = self._setObject(file_name, ob, user_login=user_login)
+    document = self._setObject(file_name, ob, user_login=user_login, container=container)
     document = self._getOb(file_name) # Call _getOb to purge cache
 
     # Reindex it and return the document
@@ -267,7 +273,7 @@
     return property_dict
 
   # WebDAV virtual folder support
-  def _setObject(self, name, ob, user_login=None):
+  def _setObject(self, name, ob, user_login=None, container=None):
     """
       The strategy is to let NullResource.PUT do everything as
       usual and at the last minute put the object in a different
@@ -311,7 +317,10 @@
                                        # can safely change its portal_type
       # Now we know the portal_type, let us find the module
       # to which we should move the document to
-      module = self.getDefaultModule(ob.portal_type)
+      if container is None:
+        module = self.getDefaultModule(ob.portal_type)
+      else:
+        module = container
       new_id = module.generateNewId()
       ob.id = new_id
       module._setObject(new_id, ob)




More information about the Erp5-report mailing list