[Zope-Checkins] SVN: Zope/trunk/ - Collector #1593: fixed dumb _get_id() implementation in

Andreas Jung andreas at andreas-jung.com
Fri Nov 26 09:20:01 EST 2004


Log message for revision 28513:
  
        - Collector #1593: fixed dumb _get_id() implementation in
          OFS.CopySupport that produced copy_of_copy_of....files
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/OFS/CopySupport.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-11-26 13:35:29 UTC (rev 28512)
+++ Zope/trunk/doc/CHANGES.txt	2004-11-26 14:20:00 UTC (rev 28513)
@@ -46,6 +46,9 @@
 
     Bugs fixed
 
+      - Collector #1593: fixed dumb _get_id() implementation in
+        OFS.CopySupport that produced copy_of_copy_of....files
+
       - Collector #1450: files in utilities/ZODBTools are now installed
         during the installation process in the 'bin' directory
 

Modified: Zope/trunk/lib/python/OFS/CopySupport.py
===================================================================
--- Zope/trunk/lib/python/OFS/CopySupport.py	2004-11-26 13:35:29 UTC (rev 28512)
+++ Zope/trunk/lib/python/OFS/CopySupport.py	2004-11-26 14:20:00 UTC (rev 28513)
@@ -14,7 +14,7 @@
 
 $Id$
 """
-import sys,  Globals, Moniker, tempfile, ExtensionClass
+import re, sys,  Globals, Moniker, tempfile, ExtensionClass
 from marshal import loads, dumps
 from urllib import quote, unquote
 from zlib import compress, decompress
@@ -113,14 +113,19 @@
             return self.manage_main(self, REQUEST)
         return cp
 
+    copy_re=re.compile('^copy[0-9]*_of_')
+
     def _get_id(self, id):
         # Allow containers to override the generation of
         # object copy id by attempting to call its _get_id
         # method, if it exists.
-        n=0
-        if (len(id) > 8) and (id[8:]=='copy_of_'):
+        copy_match=self.copy_re.match(id)
+        if (copy_match) and (copy_match.end() < len(id)):
             n=1
-        orig_id=id
+            orig_id=self.copy_re.sub('', id)
+        else:
+            n=0
+            orig_id=id
         while 1:
             if self._getOb(id, None) is None:
                 return id



More information about the Zope-Checkins mailing list