not sure if this is the right place to post patches, but since I've
already put this one into the Collector months (year ?) ago without 
it being applied...

the method manage_renameObjects in lib/python/OFS/CopySupport.py
doesn't accept to rename an objet to the same id, it's 

however, say you want to rename the objects A and B to
respectively B and A using this method, it raises an error
because B already exists.

a solution to this is to make the rename in two parts, and
here's the patch, which seems to work fine for the not too many tests
I've done:

--- CUT---
--- CopySupport.py      Mon Apr 16 18:26:20 2001
+++ CopySupport.py.new  Sun Jun 24 20:58:48 2001
@@ -281,9 +281,20 @@
         """Rename several sub-objects"""
         if len(ids) != len(new_ids):
             raise 'Bad Request','Please rename each listed object.'
+        conflicts = []
         for i in range(len(ids)):
             if ids[i] != new_ids[i]:
+                if new_ids[i] not in ids :      # may a conflict occur ?
                 self.manage_renameObject(ids[i], new_ids[i], REQUEST)
+                else :
+                        tempo = ".temporary_%i_" % i
+                        self.manage_renameObject(ids[i], tempo)
+                        conflicts.append((tempo, new_ids[i]))
+        # now we rename conflictuous objects
+        for (old, new) in conflicts :
+                self.manage_renameObject(old, new)
         if REQUEST is not None:
             return self.manage_main(self, REQUEST, update_menu=1)
         return None
--- CUT ---

NB: a better temporary id should be created.

hoping this helps.


Jerome Alet

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to