[Zope-dev] Undocumented? changes to CopySupport.py

Brian Lloyd Brian@digicool.com
Fri, 30 Jul 1999 11:03:16 -0400


> While testing my application under Zope2.0.0b1 I noticed that it no
> longer cut and pasted correctly. After a bit of digging I found that
> CopySupport.py no longer calls _postCopy() after doing a copy 
> or paste.
> As I need to do some post-copy/paste processing I have implemented
> _postCopy() in my objects. The code in CopySupport.py calls
> manage_AfterClone after doing a copy but there is no equivalent call
> after a paste. 
> Note that the class CopySource (which is documented as an 
> 'Interface for
> objects which allow themselves to be copied.') still has 
> _postCopy() as
> a member function.
> 
> Is this an oversight or is it a design decision ?

It's a design decision to simplify the protocols.
Effectively, you should be able to do everything 
that you used to be able to do with the copy protocols 
using one or more of:

    def manage_afterAdd(self, item, container): pass
    def manage_beforeDelete(self, item, container): pass
    def manage_afterClone(self, item): pass

...which are defined in lib/python/OFS/SimpleItem.py

manage_afterAdd will be called on an object after it is
added to an ObjectManger.

manage_beforeDelete will be called on an object right
before it is deleted from an ObjectManager.

manage_afterClone is called (as you noticed) after an
object is copied.

You should be able to use manage_afterAdd to handle whatever
you were doing in your _postCopy methods. If not, let us know 
so we can examine whether the protocols need to be extended...

> Are there any other changes like this and if so, are they 
> documented and
> where ? If not, any hints as to what might have changed would be
> appreciated :-) and I will attempt to document them.

I think that this is the main change as far as protocols go. 
Certainly there are a lot of new things in the code, and while
we are working on documenting them, I don't think that the 
developer docs are up to date yet. :(

Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com