[Zodb-checkins] CVS: ZODB3/ZODB - config.xml:1.1.4.7 config.py:1.1.4.6

Jeremy Hylton jeremy@zope.com
Fri, 3 Jan 2003 14:21:52 -0500


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv30603/ZODB

Modified Files:
      Tag: zconfig-schema-devel-branch
	config.xml config.py 
Log Message:
Change configuration to use datatypes for section.


=== ZODB3/ZODB/config.xml 1.1.4.6 => 1.1.4.7 ===
--- ZODB3/ZODB/config.xml:1.1.4.6	Fri Jan  3 14:03:58 2003
+++ ZODB3/ZODB/config.xml	Fri Jan  3 14:21:49 2003
@@ -2,7 +2,7 @@
 
   <sectiongroup type="storage">
 
-    <sectiontype type="filestorage">
+    <sectiontype type="filestorage" datatype="ZODB.config.FileStorage">
       <key name="path" required="yes"/>
       <key name="create" datatype="boolean" default="true"/>
       <key name="read_only" datatype="boolean" default="false"/>
@@ -10,11 +10,11 @@
       <key name="quota" datatype="integer"/>
     </sectiontype>
 
-    <sectiontype type="mappingstorage">
+    <sectiontype type="mappingstorage" datatype="ZODB.config.MappingStorage">
       <key name="name" default="Mapping Storage"/>
     </sectiontype>
 
-    <sectiontype type="fullstorage">
+    <sectiontype type="fullstorage" datatype="ZODB.config.BDBStorage">
       <key name="name" required="yes" />
       <key name="interval" datatype="time-interval" default="2m" />
       <key name="kbyte" datatype="integer" default="0" />
@@ -29,7 +29,7 @@
 
     <!-- XXX Fred promises to make it so minimal storage is just an
          extension of fullstorage -->
-    <sectiontype type="minimalstorage">
+    <sectiontype type="minimalstorage" datatype="ZODB.config.BDBStorage">
       <key name="name" required="yes" />
       <key name="interval" datatype="time-interval" default="2m" />
       <key name="kbyte" datatype="integer" default="0" />
@@ -42,7 +42,7 @@
       <key name="read_only" datatype="boolean" default="off"/>
     </sectiontype>
 
-    <sectiontype type="zeoclient">
+    <sectiontype type="zeoclient" datatype="ZODB.config.ZEOClient">
       <multikey name="server" datatype="socket-address" required="yes"/>
       <key name="storage" default="1"/>
       <key name="cache_size" datatype="integer" default="20000000"/>
@@ -54,6 +54,13 @@
       <key name="wait" datatype="boolean" default="on"/>
       <key name="read_only" datatype="boolean" default="off"/>
       <key name="read_only_fallback" datatype="boolean" default="off"/>
+    </sectiontype>
+
+    <sectiontype type="demostorage">
+      <!--datatype="ZODB.config.DemoStorage"-->
+      <key name="name" default="Demo Storage"/>
+      <section type="storage" name="*" attribute="base"/>
+      <key name="quota" datatype="integer"/>
     </sectiontype>
 
   </sectiongroup>


=== ZODB3/ZODB/config.py 1.1.4.5 => 1.1.4.6 ===
--- ZODB3/ZODB/config.py:1.1.4.5	Fri Jan  3 14:03:14 2003
+++ ZODB3/ZODB/config.py	Fri Jan  3 14:21:49 2003
@@ -43,36 +43,64 @@
     return databaseFromConfig(config)
 
 def databaseFromConfig(config):
-    return ZODB.DB(storageFromConfig(config.storage),
+    return ZODB.DB(config.storage.open(),
                    pool_size=config.pool_size,
                    cache_size=config.cache_size,
                    version_pool_size=config.version_pool_size,
                    version_cache_size=config.version_cache_size)
 
-class StorageOpener:
+class StorageConfig:
 
-    def fromConfig(self, config):
-        meth = getattr(self, config.getSectionType())
-        return meth(config)
+    def __init__(self, config):
+        self.config = config
 
-    def mappingstorage(self, config):
+    def open(self):
+        raise NotImplementedError
+
+class MappingStorage(StorageConfig):
+
+    def open(self):
         from ZODB.MappingStorage import MappingStorage
-        return MappingStorage(config.name)
+        return MappingStorage(self.config.name)
 
-    def filestorage(self, config):
+class FileStorage(StorageConfig):
+
+    def open(self):
         from ZODB.FileStorage import FileStorage
-        return FileStorage(config.path,
-                           create=config.create,
-                           read_only=config.read_only,
-                           stop=config.stop,
-                           quota=config.quota)
+        return FileStorage(self.config.path,
+                           create=self.config.create,
+                           read_only=self.config.read_only,
+                           stop=self.config.stop,
+                           quota=self.config.quota)
+
+class ZEOClient(StorageConfig):
 
-    def _bdbstorage(self, config):
+    def open(self):
+        from ZEO.ClientStorage import ClientStorage
+        # config.server is a multikey of socket-address values
+        # where the value is a socket family, address tuple.
+        L = [addr for family, addr in self.config.server]
+        return ClientStorage(
+            L,
+            storage=self.config.storage,
+            cache_size=self.config.cache_size,
+            name=self.config.name,
+            client=self.config.client,
+            var=self.config.var,
+            min_disconnect_poll=self.config.min_disconnect_poll,
+            max_disconnect_poll=self.config.max_disconnect_poll,
+            wait=self.config.wait,
+            read_only=self.config.read_only,
+            read_only_fallback=self.config.read_only_fallback)
+
+class BDBStorage(StorageConfig):
+    
+    def open(self):
         from BDBStorage.BerkeleyBase import BerkeleyConfig
         from BDBStorage.BDBFullStorage import BDBFullStorage
         from BDBStorage.BDBMinimalStorage import BDBMinimalStorage
         # Figure out which class we want
-        sectiontype = config.getSectionType()
+        sectiontype = self.config.getSectionType()
         storageclass = {'fullstorage': BDBFullStorage,
                         'minimalstorage': BDBMinimalStorage,
                         }[sectiontype]
@@ -80,27 +108,5 @@
         for name in dir(BerkeleyConfig):
             if name.startswith('_'):
                 continue
-            setattr(bconf, name, getattr(config, name))
-        return storageclass(config.name, config=bconf)
-
-    fullstorage = _bdbstorage
-    minimalstorage = _bdbstorage
-
-    def zeoclient(self, config):
-        from ZEO.ClientStorage import ClientStorage
-        # config.server is a multikey of socket-address values
-        # where the value is a socket family, address tuple.
-        L = [addr for family, addr in config.server]
-        return ClientStorage(L,
-                             storage=config.storage,
-                             cache_size=config.cache_size,
-                             name=config.name,
-                             client=config.client,
-                             var=config.var,
-                             min_disconnect_poll=config.min_disconnect_poll,
-                             max_disconnect_poll=config.max_disconnect_poll,
-                             wait=config.wait,
-                             read_only=config.read_only,
-                             read_only_fallback=config.read_only_fallback)
-
-storageFromConfig = StorageOpener().fromConfig
+            setattr(bconf, name, getattr(self.config, name))
+        return storageclass(self.config.name, config=bconf)