Commit 870f9cf4 authored by 's avatar

Added contributed patch that fixes bug in copied-object id generation.

parent 97201e83
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__doc__="""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.31 $'[11:-2] __version__='$Revision: 1.32 $'[11:-2]
import sys, string, Globals, Moniker, tempfile, ExtensionClass import sys, string, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps from marshal import loads, dumps
...@@ -424,13 +424,19 @@ def absattr(attr): ...@@ -424,13 +424,19 @@ def absattr(attr):
return attr return attr
def _get_id(ob, id): def _get_id(ob, id):
# Allow containers to override the generation of
# object copy id by attempting to call its _get_id
# method, if it exists.
if hasattr(ob, '_get_id'):
return ob._get_id(id)
try: ob=ob.aq_base try: ob=ob.aq_base
except: pass except: pass
n=0 n=0
if (len(id) > 8) and (id[8:]=='copy_of_'): if (len(id) > 8) and (id[8:]=='copy_of_'):
n=1 n=1
orig_id=id
while (hasattr(ob, id)): while (hasattr(ob, id)):
id='copy%s_of_%s' % (n and n+1 or '', id) id='copy%s_of_%s' % (n and n+1 or '', orig_id)
n=n+1 n=n+1
return id return id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment