[Zope-CVS] CVS: Products/DBTab - StorageTypes.py:1.8 dbtab.conf.in:1.10 version.txt:1.12

Shane Hathaway shane@zope.com
Wed, 21 May 2003 14:37:43 -0400


Update of /cvs-repository/Products/DBTab
In directory cvs.zope.org:/tmp/cvs-serv7361

Modified Files:
	StorageTypes.py dbtab.conf.in version.txt 
Log Message:
Added support for DemoStorage layering.

=== Products/DBTab/StorageTypes.py 1.7 => 1.8 ===
--- Products/DBTab/StorageTypes.py:1.7	Mon Jan  6 11:56:38 2003
+++ Products/DBTab/StorageTypes.py	Wed May 21 14:37:43 2003
@@ -123,9 +123,44 @@
     return kw
 
 
+def convertDemoStorageArgs(base_type=None, **kw):
+    if base_type:
+        # XXX partly copied from DBTab.py
+        pos = base_type.rfind('.')
+        if pos >= 0:
+            # Specified the module
+            module = base_type[:pos]
+            class_name = base_type[pos + 1:]
+        else:
+            module = None
+            class_name = base_type
+        converter = None
+        info = storage_types.get(class_name)
+        if info:
+            if not module or info[0] == module:
+                # Use a default argument converter and maybe a default module.
+                module, converter = info
+        elif not module:
+            raise DBTabConfigurationError(
+                'Unknown storage type: %s' % base_type)
+        m = __import__(module, globals(), locals(), [class_name])
+        base_class = getattr(m, class_name)
+
+        # Pass all of the remaining arguments to the base storage constructor.
+        base_args = kw
+        if converter is not None:
+            base_args = converter(**base_args)
+
+        base = base_class(**base_args)
+        kw = {'base': base, 'name': kw['name']}
+    else:
+        base = None
+    return kw
+
+
 storage_types = {
     'FileStorage': ('ZODB.FileStorage', convertFileStorageArgs),
-    'DemoStorage': ('ZODB.DemoStorage', None),
+    'DemoStorage': ('ZODB.DemoStorage', convertDemoStorageArgs),
     'MappingStorage': ('ZODB.MappingStorage', None),
     'TemporaryStorage': ('Products.TemporaryFolder.TemporaryStorage', None),
     'ClientStorage': ('ZEO.ClientStorage', convertClientStorageArgs),


=== Products/DBTab/dbtab.conf.in 1.9 => 1.10 ===
--- Products/DBTab/dbtab.conf.in:1.9	Mon Apr 21 12:39:57 2003
+++ Products/DBTab/dbtab.conf.in	Wed May 21 14:37:43 2003
@@ -568,5 +568,36 @@
 
 # [Database: Volatile Demo]
 # mount_paths=/
-# auto_create=1
+# container_class=OFS.Folder.Folder
+
+
+######################################################################
+##
+## DemoStorage has a layering feature.  You can use DemoStorage to
+## make in-memory changes to a read-only database.  This is
+## particularly useful for Zope demonstrations, since it allows you to
+## make changes without writing to the hard drive and later reset to
+## the original data simply by restarting.
+##
+## To use the DemoStorage layering feature with DBTab, provide a
+## 'base_type' configuration option and supply all of the options for
+## the base storage class in the same configuration block.  The
+## example below shows how to create a DemoStorage layered over a
+## FileStorage.
+##
+## Note that you add a DemoStorage layer to almost any storage
+## configuration by renaming the 'type' option to 'base_type' and
+## using 'DemoStorage' for the 'type' option.  Conversely, you can
+## remove a DemoStorage layer by removing the 'type' option and
+## renaming 'base_type' to 'type'.
+##
+######################################################################
+
+# [Storage: Layered Demo]
+# type=DemoStorage
+# base_type=FileStorage
+# file_name=%(CLIENT_HOME)s/Data.fs
+
+# [Database: Layered Demo]
+# mount_paths=/
 


=== Products/DBTab/version.txt 1.11 => 1.12 ===
--- Products/DBTab/version.txt:1.11	Mon Apr 21 12:39:57 2003
+++ Products/DBTab/version.txt	Wed May 21 14:37:43 2003
@@ -1 +1 @@
-DBTab-1.2
+DBTab-1.2+