[Zope-Checkins] CVS: Zope/lib/python/OFS - CopySupport.py:1.80

Shane Hathaway shane@cvs.zope.org
Wed, 12 Jun 2002 14:15:53 -0400


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv20025

Modified Files:
	CopySupport.py 
Log Message:
Use a subtransaction to ensure the data being copied is current and to get
the _p_jar attributes set.


=== Zope/lib/python/OFS/CopySupport.py 1.79 => 1.80 ===
 
     def _getCopy(self, container):
+        # Commit a subtransaction to:
+        # 1) Make sure the data about to be exported is current
+        # 2) Ensure self._p_jar and container._p_jar are set even if
+        #    either one is a new object
+        get_transaction().commit(1)
+
+        if self._p_jar is None:
+            raise CopyError, (
+                'Object "%s" needs to be in the database to be copied' %
+                `self`)
+        if container._p_jar is None:
+            raise CopyError, (
+                'Container "%s" needs to be in the database' %
+                `container`)
+
         # Ask an object for a new copy of itself.
         f=tempfile.TemporaryFile()
         self._p_jar.exportFile(self._p_oid,f)
@@ -418,8 +433,6 @@
     def cb_isCopyable(self):
         # Is object copyable? Returns 0 or 1
         if not (hasattr(self, '_canCopy') and self._canCopy(0)):
-            return 0
-        if hasattr(self, '_p_jar') and self._p_jar is None:
             return 0
         if not self.cb_userHasCopyOrMovePermission():
             return 0