[Zope-dev] Copy without taking including the structure

Petter Enholm Petter Enholm" <pe@snapper.no
Fri, 5 Jul 2002 19:50:16 +0200


Hi,

I am implementing a kind of Copy function which will strip off the sub level
of object being copied. The idea is to copy only the object marked for
copying - without the sub objects.
(For those interested: I use these objects as special kind of reference
objects  in my structure.......)

In the new copy routine I have added these lines which avoids having the sub
level created:

[ ....]

newObject = ob._getCopy(self)

for zob in newObject._objects:
   delattr(newObject, zob['id'])
newObject._objects = ()

[ ..... ]

self._setObject(newObject.id,newObject)   # add the object to the Zope
database

... delattr is the same method as used by _delOb, so I assumed this is the
safe way of doing it.
Can anyone tell me if this is not OK ? It seems to work very well ....

Best regards

Petter Enholm
Snapper as
www.snapper.no