[Zope-Checkins] CVS: Packages/OFS - CopySupport.py:1.85.2.9

Florent Guillaume fg at nuxeo.com
Fri Nov 26 09:59:24 EST 2004


Update of /cvs-repository/Packages/OFS
In directory cvs.zope.org:/tmp/cvs-serv8941/lib/python/OFS

Modified Files:
      Tag: Zope-2_7-branch
	CopySupport.py 
Log Message:
Better fix for _get_id, and unit tests.


=== Packages/OFS/CopySupport.py 1.85.2.8 => 1.85.2.9 ===
--- Packages/OFS/CopySupport.py:1.85.2.8	Fri Nov 26 09:22:16 2004
+++ Packages/OFS/CopySupport.py	Fri Nov 26 09:58:53 2004
@@ -13,7 +13,7 @@
 __doc__="""Copy interface"""
 __version__='$Revision$'[11:-2]
 
-import re, 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
@@ -28,6 +28,8 @@
 
 CopyError='Copy Error'
 
+copy_re = re.compile('^copy([0-9]*)_of_(.*)')
+
 _marker=[]
 class CopyContainer(ExtensionClass.Base):
     """Interface for containerish objects which allow cut/copy/paste"""
@@ -112,19 +114,17 @@
             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.
-        copy_match=self.copy_re.match(id)
-        if (copy_match) and (copy_match.end() < len(id)):
-            n=1
-            orig_id=self.copy_re.sub('', id)
+        match = copy_re.match(id)
+        if match:
+            n = int(match.group(1) or '1')
+            orig_id = match.group(2)
         else:
-            n=0
-            orig_id=id
+            n = 0
+            orig_id = id
         while 1:
             if self._getOb(id, None) is None:
                 return id



More information about the Zope-Checkins mailing list