[Zope-dev] Minor Fix to CopySupport.py
Stefan Franke
sfranke@cdc-group.com
Mon, 12 Apr 1999 18:30:05 +0200
The current CVS's CopySupport._get_id funtion is a little buggy.
When pasting a copied object more than one time, the generated
Ids are
[original]
[copy of original]
copy2 of copy of original
copy3 of copy2 of copy of original
...
which is misleading. The attached function code (sorry,
I have no diff available) fixes this to
[original]
[copy of original]
copy2 of original
copy3 of original
...
and contains a proposal also: The first two lines
try: return ob._get_id(id)
except AttributeError: pass
call a container's _get_id method if available to allow customization.
* * *
If you change CopySupport.py please have a look to
"[Zope-dev] Possible bug in CopySupport.py (Zope 1.10.2)"
as well, which I posted two weeks ago to zope-dev
Thanks,
Stefan
* * *
[CopySupport.py, line 426]
def _get_id(ob, id):
try: return ob._get_id(id)
except AttributeError: pass
try: ob=ob.aq_base
except: pass
n=0
if (len(id) > 8) and (id[8:]=='copy_of_'):
n=1
orig_id = id
while (hasattr(ob, id)):
id='copy%s_of_%s' % (n and n+1 or '', orig_id)
n=n+1
return id