SVN: Zope/trunk/src/OFS/ObjectManager.py remove parent pointer while exporting

David Glick <[email protected]>
Newsgroups gmane.comp.web.zope.cvs
Message-ID <20110311145359.D2FF3941C4__25120.1495215811$1299855252$gmane$org@cvs.zope.org>
Log message for revision 120865:
  remove parent pointer while exporting

Changed:
  U   Zope/trunk/src/OFS/ObjectManager.py

-=-
Modified: Zope/trunk/src/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/ObjectManager.py	2011-03-11 14:48:34 UTC (rev 120864)
+++ Zope/trunk/src/OFS/ObjectManager.py	2011-03-11 14:53:59 UTC (rev 120865)
@@ -22,6 +22,7 @@
 import os
 import re
 import sys
+import transaction
 
 from AccessControl import ClassSecurityInfo
 from AccessControl.class_init import InitializeClass
@@ -584,11 +585,25 @@
 
         cfg = getConfiguration()
         f = os.path.join(cfg.clienthome, '%s.%s' % (id, suffix))
-        if toxml:
-            exportXML(ob._p_jar, ob._p_oid, f)
-        else:
-            ob._p_jar.exportFile(ob._p_oid, f)
 
+        ob = aq_base(ob)
+        parent = getattr(ob, '__parent__', _marker)
+        if parent is not _marker:
+            sp = transaction.savepoint(True)
+            del ob.__parent__
+            # create a savepoint so that the export includes the version
+            # without a __parent__ pointer
+            transaction.savepoint(True)
+        try:
+            if toxml:
+                exportXML(ob._p_jar, ob._p_oid, f)
+            else:
+                ob._p_jar.exportFile(ob._p_oid, f)
+        finally:
+            if parent is not _marker:
+                # roll back so that we don't actually remove the __parent__
+                sp.rollback()
+
         if REQUEST is not None:
             return self.manage_main(self, REQUEST,
                 manage_tabs_message=

_______________________________________________
Zope-Checkins maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.