[Zope-CVS] CVS: Products/AdaptableStorage/tests - testZope2FS.py:1.3

Shane Hathaway shane@zope.com
Thu, 5 Dec 2002 12:38:48 -0500


Update of /cvs-repository/Products/AdaptableStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv16479/tests

Modified Files:
	testZope2FS.py 
Log Message:
The following comments might not make sense to anyone but me right now,
but someday it might be useful for historical purposes.

- Removed ClassificationAspect.  This strategy simply can't work correctly.
  The load() method of FSClassificationSection was using the wrong object
  mapper to classify filenames (it was using the child's rather than the
  container's object mapper), revealing that classification should be
  known only to the container, not the object.

- Added a "preserve" write mode to FSConnection, enabling classification to
  be preserved even though other sections get changed.

- Simplified FSClassificationSection using the new preserve write mode.

- Since ClassificationAspect no longer exists, nothing will ever delegate
  aspect loading/storing to MetaTypeClassifier.  Removed the methods that
  implemented the IAspectSerializer interface.

- Now gateways can return None as the serial, making them invisible to the
  hash computation.

- Added tests that verify that classifications get stored in preserve mode.

- Turned the debug flag back off :-)



=== Products/AdaptableStorage/tests/testZope2FS.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/tests/testZope2FS.py:1.2	Tue Dec  3 18:10:54 2002
+++ Products/AdaptableStorage/tests/testZope2FS.py	Thu Dec  5 12:38:47 2002
@@ -38,6 +38,7 @@
         self.path = path
         dm, fs_conn = createDomainMapper(path)
         self.dm = dm
+        self.fs_conn = fs_conn
         resource = StaticResource(dm)
         storage = ASStorage(resource, [fs_conn])
         self.storage = storage
@@ -71,16 +72,52 @@
             f._setObject(f2.id, f2, set_owner=0)
             get_transaction().commit()
 
+            f3 = Folder()
+            f3.id = 'Eve'
+            f2._setObject(f3.id, f3, set_owner=0)
+            get_transaction().commit()
+
             conn2 = self.db.open()
             try:
                 app = conn2.root()['Application']
                 self.assert_(hasattr(app, 'Holidays'))
                 self.assert_(hasattr(app.Holidays, 'Christmas'))
+                self.assert_(hasattr(app.Holidays.Christmas, 'Eve'))
             finally:
                 conn2.close()
 
         finally:
             conn.close()
+
+    def testClassificationPreservation(self):
+        # Ensure that classification doesn't get forgotten, even though
+        # it's the container that writes it, not the object.
+        conn = self.db.open()
+        try:
+            from OFS.Folder import Folder
+            app = conn.root()['Application']
+            f = Folder()
+            f.id = 'Holidays'
+            app._setObject(f.id, f, set_owner=0)
+            get_transaction().commit()
+
+            f2 = Folder()
+            f2.id = 'Christmas'
+            f._setObject(f2.id, f2, set_owner=0)
+            get_transaction().commit()
+
+            f3 = Folder()
+            f3.id = 'Eve'
+            f2._setObject(f3.id, f3, set_owner=0)
+            get_transaction().commit()
+
+            for folder in (f, f2, f3):
+                mapper, key = conn.getOIDInfo(folder._p_oid)
+                text = self.fs_conn.readSection(key, 'classification')
+                self.assertEqual(text.strip(), 'meta_type=Folder')
+        finally:
+            conn.close()
+        
 
 
 if __name__ == '__main__':