[Zope-dev] CopySupport.py patch

zope-dev@pi.slcc.edu zope-dev@pi.slcc.edu
Fri, 21 Jan 2000 13:24:33 -0700 (MST)


I am creating a product and have a special situation where a certain
object must not be pasted in certain places on the Zope hierarchy.
The CopySource class in OFS/CopySupport.py provides a _notifyOfCopyTo
mechanism but the mechanism isn't fully supported in the CopyContainer
class.  Please use the following patch which corrects the problem.  I
have simply copied the _notifyOfCopyTo call from another part of the
file.  This is derived from the Zope 2.1.1 sources, but hopefully the
development version hasn't changed a lot.

Shane Hathaway

diff -Naur CopySupport.py.orig CopySupport.py
--- CopySupport.py.orig Fri Jan 21 13:01:00 2000
+++ CopySupport.py      Fri Jan 21 13:04:25 2000
@@ -203,7 +203,14 @@
             # Copy operation
             for ob in oblist:
                 if not ob.cb_isCopyable():
-                     raise CopyError, eNotSupported % absattr(ob.id)
+                    raise CopyError, eNotSupported % absattr(ob.id)
+                try:
+                    ob._notifyOfCopyTo(self, 0)
+                except:
+                    raise CopyError, MessageDialog(
+                        title='Paste Error',
+                        message=sys.exc_value,
+                        action ='manage_main')
                 ob=ob._getCopy(self)
                 ob.manage_afterClone(ob)
                 id=self._get_id(absattr(ob.id))