[Checkins] SVN: zc.beforestorage/branches/dev/s Refined documentation a little in preparation for release and

Jim Fulton jim at zope.com
Tue Jan 22 20:13:37 EST 2008


Log message for revision 83105:
  Refined documentation a little in preparation for release and
  consolidated config test with readme.
  
  Added missing methods needed by zeo.
  

Changed:
  U   zc.beforestorage/branches/dev/setup.py
  U   zc.beforestorage/branches/dev/src/zc/beforestorage/README.txt
  U   zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py
  U   zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py
  D   zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt

-=-
Modified: zc.beforestorage/branches/dev/setup.py
===================================================================
--- zc.beforestorage/branches/dev/setup.py	2008-01-23 01:08:52 UTC (rev 83104)
+++ zc.beforestorage/branches/dev/setup.py	2008-01-23 01:13:36 UTC (rev 83105)
@@ -1,14 +1,43 @@
+##############################################################################
+#
+# Copyright (c) Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import os
+
 from setuptools import setup, find_packages
 
+def read(rname):
+    return open(os.path.join(os.path.dirname(__file__), *rname.split('/')
+                             )).read()
+
 entry_points = """
 """
 
+long_description = (
+        read('src/zc/beforestorage/README.txt')
+        + '\n' +
+        'Download\n'
+        '--------\n'
+        )
+
+open('doc.txt', 'w').write(long_description)
+
 setup(
     name = 'zc.beforestorage',
     version = '0.1',
     author = 'Jim Fulton',
     author_email = 'jim at zope.com',
-    description = '',
+    description = 'View storage before a given time',
+    long_description=long_description,
     license = 'ZPL 2.1',
     
     packages = find_packages('src'),

Modified: zc.beforestorage/branches/dev/src/zc/beforestorage/README.txt
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/README.txt	2008-01-23 01:08:52 UTC (rev 83104)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/README.txt	2008-01-23 01:13:36 UTC (rev 83105)
@@ -1,3 +1,4 @@
+==============
 Before Storage
 ==============
 
@@ -36,9 +37,62 @@
 provides a read-only view of an underlying storage as of a particular
 point in time.
 
-To see how this works, we'll create a file storage, and use a before
-storage to provide views on it.
+Change history
+==============
 
+0.1 (2008-01-??)
+----------------
+
+Initial release.
+
+Using ZConfig to configure Before storages
+==========================================
+
+To use before storages from ZConfig configuration files, you need to
+import zc.beforestorage and then use a before storage section.
+
+    >>> import ZODB.config
+    >>> storage = ZODB.config.storageFromString("""
+    ...
+    ... %import zc.beforestorage
+    ...
+    ... <before>
+    ...     before 2008-01-21
+    ...     <filestorage>
+    ...         path my.fs
+    ...     </filestorage>
+    ... </before>
+    ... """)
+
+    >>> storage
+    <Before: my.fs before 2008-01-21 00:00:00.000000>
+
+    >>> storage.close()
+
+If we leave off the before option, we'll use the current time:
+
+    >>> storage = ZODB.config.storageFromString("""
+    ...
+    ... %import zc.beforestorage
+    ...
+    ... <before>
+    ...     <filestorage>
+    ...         path my.fs
+    ...     </filestorage>
+    ... </before>
+    ... """)
+
+    >>> storage
+    <Before: my.fs before 2008-01-21 18:22:48.000000>
+
+    >>> storage.close()
+
+Demonstration (doctest)
+=======================
+
+To see how this works at the Python level, we'll create a file
+storage, and use a before storage to provide views on it.
+
     >>> import ZODB.FileStorage
     >>> fs = ZODB.FileStorage.FileStorage('Data.fs')
     >>> from ZODB.DB import DB
@@ -96,7 +150,7 @@
 Let's run through the storage methods:
 
     >>> b5.getName()
-    'Data.fs before 2008-01-21 18:22:50.000000'
+    'Data.fs before 2008-01-21 18:22:56.000000'
 
     >>> b5.getSize() == fs.getSize()
     True
@@ -132,6 +186,9 @@
     >>> s2 == transactions[4]
     True
 
+    >>> b5.lastTid(root._p_oid) == transactions[4]
+    True
+
     >>> b5.new_oid()
     Traceback (most recent call last):
     ...
@@ -172,6 +229,7 @@
     ...
     StorageTransactionError: ...
 
+    >>> b5.tpc_transaction()
     >>> b5.tpc_abort(transaction)
 
 Before storages don't support undo:
@@ -217,7 +275,7 @@
 The timestamp may be passed directory, or as an ISO time.  For
 example:
 
-    >>> b5 = zc.beforestorage.Before(fs, '2008-01-21T18:22:50')
+    >>> b5 = zc.beforestorage.Before(fs, '2008-01-21T18:22:56')
     >>> db5 = DB(b5)
     >>> conn5 = db5.open()
     >>> root5 = conn5.root()

Modified: zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py	2008-01-23 01:08:52 UTC (rev 83104)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py	2008-01-23 01:13:36 UTC (rev 83105)
@@ -82,6 +82,9 @@
     def isReadOnly(self):
         return True
 
+    def lastTid(self, oid):
+        return self.load(oid)[1]
+
     def lastTransaction(self):
         return ZODB.utils.p64(ZODB.utils.u64(self.before)-1)
 
@@ -132,6 +135,9 @@
     def tpc_finish(self, transaction, func = lambda: None):
         raise ZODB.POSException.StorageTransactionError(self, transaction)
 
+    def tpc_transaction(self):
+        return None
+
     def tpc_vote(self, transaction):
         raise ZODB.POSException.StorageTransactionError(self, transaction)
 

Modified: zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py	2008-01-23 01:08:52 UTC (rev 83104)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py	2008-01-23 01:13:36 UTC (rev 83105)
@@ -35,7 +35,7 @@
 def test_suite():
     return unittest.TestSuite((
         doctest.DocFileSuite(
-            'README.txt', 'zconfig.txt',
+            'README.txt',
             setUp=setUp, tearDown=zope.testing.setupstack.tearDown,
             ),
         ))

Deleted: zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt	2008-01-23 01:08:52 UTC (rev 83104)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt	2008-01-23 01:13:36 UTC (rev 83105)
@@ -1,39 +0,0 @@
-Using ZConfig to configure Before storages
-==========================================
-
-To use before storages from ZConfig configuration files, you need to
-import zc.beforestorage and then use a before storage section.
-
-    >>> import ZODB.config
-    >>> storage = ZODB.config.storageFromString("""
-    ...
-    ... %import zc.beforestorage
-    ...
-    ... <before>
-    ...     before 2008-01-21
-    ...     <filestorage>
-    ...         path Data.fs
-    ...     </filestorage>
-    ... </before>
-    ... """)
-
-    >>> storage
-    <Before: Data.fs before 2008-01-21 00:00:00.000000>
-
-    >>> storage.close()
-
-If we leave off the before option, we'll use the current time:
-
-    >>> storage = ZODB.config.storageFromString("""
-    ...
-    ... %import zc.beforestorage
-    ...
-    ... <before>
-    ...     <filestorage>
-    ...         path Data.fs
-    ...     </filestorage>
-    ... </before>
-    ... """)
-
-    >>> storage
-    <Before: Data.fs before 2008-01-21 18:22:48.000000>



More information about the Checkins mailing list