[Checkins] SVN: zc.beforestorage/branches/dev/src/zc/beforestorage/
Added ZConfig support.
Jim Fulton
jim at zope.com
Mon Jan 21 14:43:46 EST 2008
Log message for revision 83071:
Added ZConfig support.
Changed:
U zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py
A zc.beforestorage/branches/dev/src/zc/beforestorage/component.xml
U zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py
A zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt
-=-
Modified: zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py 2008-01-21 19:23:43 UTC (rev 83070)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/__init__.py 2008-01-21 19:43:45 UTC (rev 83071)
@@ -51,6 +51,9 @@
ZODB.TimeStamp.TimeStamp(self.before),
)
+ def __repr__(self):
+ return "<%s: %s>" % (self.__class__.__name__, self.getName())
+
def getSize(self):
return self.storage.getSize()
@@ -131,3 +134,14 @@
def tpc_vote(self, transaction):
raise ZODB.POSException.StorageTransactionError(self, transaction)
+
+class ZConfig:
+
+ def __init__(self, config):
+ self.config = config
+ self.name = config.getSectionName()
+
+ def open(self):
+ base = self.config.base.open()
+ return Before(base, self.config.before)
+
Added: zc.beforestorage/branches/dev/src/zc/beforestorage/component.xml
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/component.xml (rev 0)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/component.xml 2008-01-21 19:43:45 UTC (rev 83071)
@@ -0,0 +1,22 @@
+<component>
+ <description>
+ Definitions for before storages.
+ </description>
+
+ <sectiontype name="before" datatype="zc.beforestorage.ZConfig"
+ implements="ZODB.storage">
+
+ <section type="ZODB.storage" name="*" attribute="base" required="yes" />
+
+ <key name="before" datatype="string" required="no">
+ <description>
+ The time before which data will be read from the base storage.
+ This is of the form: YYYY-MM-DDTHH:MM:SS.SSS, where trailing
+ time data is optional. That is: YYYY-MM-DDTHH:MM:SS,
+ YYYY-MM-DDTHH:MM, YYYY-MM-DDTHH, and YYYY-MM-DD, are all valid
+ forms.
+ </description>
+ </key>
+ </sectiontype>
+
+</component>
Property changes on: zc.beforestorage/branches/dev/src/zc/beforestorage/component.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py 2008-01-21 19:23:43 UTC (rev 83070)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/tests.py 2008-01-21 19:43:45 UTC (rev 83071)
@@ -35,7 +35,7 @@
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
- 'README.txt',
+ 'README.txt', 'zconfig.txt',
setUp=setUp, tearDown=zope.testing.setupstack.tearDown,
),
))
Added: zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt
===================================================================
--- zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt (rev 0)
+++ zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt 2008-01-21 19:43:45 UTC (rev 83071)
@@ -0,0 +1,39 @@
+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>
Property changes on: zc.beforestorage/branches/dev/src/zc/beforestorage/zconfig.txt
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list