[Zope-CVS] CVS: Products/Ape/lib/apelib/fs - annotated.py:1.3 structure.py:1.7

Shane Hathaway shane at zope.com
Thu Feb 19 01:44:34 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/fs
In directory cvs.zope.org:/tmp/cvs-serv14876/lib/apelib/fs

Modified Files:
	annotated.py structure.py 
Log Message:
Two changes that make storing the Zope root object reasonable:

  - Pickled remainders are now encoded in base64 and stored in the
    properties file.  Ape no longer creates .remainder files, although
    it will read them.  This reduces the number of files Ape creates
    and sets a precedent that any annotation can contain a pickle
    as long as it's encoded as text.

  - There is now one PersistentMappingSerializer.  It stores both
    references and simple objects.  To accomplish this, it has to
    store reference values differently from non-reference values.
    The non-references get pickled and stored in an annotation called 
    "other". 

In testing, Ape successfully acted as the main Zope 
database.  Woohoo!  (A little Zope hack was required, but it 
should be possible to fix that.)



=== Products/Ape/lib/apelib/fs/annotated.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/fs/annotated.py:1.2	Mon Feb  2 10:07:20 2004
+++ Products/Ape/lib/apelib/fs/annotated.py	Thu Feb 19 01:44:03 2004
@@ -89,7 +89,7 @@
         try:
             data = self.ops.readfile(rem_fn, 0)
         except IOError:
-            # The remainder file apparently does not exist
+            # The remainder file does not exist.
             pass
         else:
             res[remainder_ann] = data
@@ -135,13 +135,12 @@
         items = anns.items()
         items.sort()
         for name, value in items:
-            if name == remainder_ann:
-                # Write to the remainder file.
-                rem_data = value
-            else:
-                # Write a section of the properties file.
-                props_data += self.formatSection(name, value)
+            # Write a section of the properties file.
+            props_data += self.formatSection(name, value)
         self.writeOrRemove(props_fn, 1, props_data)
+        # XXX Now that the remainder is folded into the properties
+        # file, writeOrRemove() no longer needs to be a separate
+        # method.
         self.writeOrRemove(rem_fn, 0, rem_data)
         self._anns_cache.invalidate(path)
         # The file might be new, so invalidate the directory.


=== Products/Ape/lib/apelib/fs/structure.py 1.6 => 1.7 ===
--- Products/Ape/lib/apelib/fs/structure.py:1.6	Tue Feb 17 00:25:11 2004
+++ Products/Ape/lib/apelib/fs/structure.py	Thu Feb 19 01:44:03 2004
@@ -200,3 +200,14 @@
         c.writeDirectory(p, names)
         names.sort()
         return tuple(names)
+
+
+def root_mapping():
+    """Returns a gateway suitable for storing the root persistent mapping.
+    """
+    from apelib.core.gateways import CompositeGateway
+    from properties import FSAnnotationData
+    g = CompositeGateway()
+    g.add('references', RootDirectoryItems())
+    g.add('others', FSAnnotationData('others'))
+    return g




More information about the Zope-CVS mailing list