[Zope] Extend copy/move protocol to object instantiation?

Mark Millikan mmillikan@vfa.com
Tue, 16 Feb 1999 15:17:00 -0500


The copy/move protocol in 'CopySupport.py' is quite nice in that it
allows the object which is being moved/copied to participate in the
operation, including rejecting the operation or cleaning up at the
conclusion of the operation. I found a need for something similar when 
objects are first installed in a folder(ish) location: 'scope out
the neighborhood' and  'make yourself at home' hooks.

-----------------------------------------------------

class anyClass:

    ...

    def addsubs(self):
        '''add sub category field names'''
        resobj=self.aq_parent.catlist1()
        res =[]
        for field in resobj._searchable_result_columns():
            res.append(field)
        self.fields=res

    def makeyourselfathome(self):
        """parent specific installation hook"""
        self.addsubs()
                       
def addAnyClassObject(self,id,title,REQUEST=None):
    """Create an Object and install it in its parent Folder	
    The argument 'self' will be bound to the parent Folder.
    """
    ob=anyClass(id)
    self._setObject(id, ob)
    ob.__of__(self).makeyourselfathome()
    if REQUEST is not None:
        return self.manage_main(self,REQUEST)

-------------------------------------------------------------

Would it make sense to add another 'op' type to
CopySource._NotifyOfCopyTo() and CopySource._postCopy() to indicate a
'first home' operation?

MAM