Commit 0a4174e7 authored by Fred Drake's avatar Fred Drake

Modify the BDB storage types in the ZConfig schema component so there is less

repitition and no magical guessing of type names in the datatypes.
parent 66121412
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
<key name="name" default="Mapping Storage"/> <key name="name" default="Mapping Storage"/>
</sectiontype> </sectiontype>
<sectiontype name="fullstorage" datatype=".BDBStorage" <!-- The BDB storages probably need to be revised somewhat still.
The extension relationship seems a little odd.
-->
<sectiontype name="fullstorage" datatype=".BDBFullStorage"
implements="storage"> implements="storage">
<key name="name" required="yes" /> <key name="name" required="yes" />
<key name="interval" datatype="time-interval" default="2m" /> <key name="interval" datatype="time-interval" default="2m" />
...@@ -33,21 +36,8 @@ ...@@ -33,21 +36,8 @@
<key name="read-only" datatype="boolean" default="off"/> <key name="read-only" datatype="boolean" default="off"/>
</sectiontype> </sectiontype>
<!-- XXX Fred promises to make it so minimal storage is just an <sectiontype name="minimalstorage" datatype=".BDBMinimalStorage"
extension of fullstorage --> implements="storage" extends="fullstorage"/>
<sectiontype name="minimalstorage" datatype=".BDBStorage"
implements="storage">
<key name="name" required="yes" />
<key name="interval" datatype="time-interval" default="2m" />
<key name="kbyte" datatype="integer" default="0" />
<key name="min" datatype="integer" default="0" />
<key name="logdir" />
<key name="cachesize" datatype="byte-size" default="128MB" />
<key name="frequency" datatype="time-interval" default="0" />
<key name="packtime" datatype="time-interval" default="4h" />
<key name="classicpack" datatype="integer" default="0" />
<key name="read-only" datatype="boolean" default="off"/>
</sectiontype>
<sectiontype name="zeoclient" datatype=".ZEOClient" <sectiontype name="zeoclient" datatype=".ZEOClient"
implements="storage"> implements="storage">
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Open database and storage from a configuration. """Open database and storage from a configuration.
$Id: config.py,v 1.8 2003/01/13 16:28:29 fdrake Exp $""" $Id: config.py,v 1.9 2003/01/16 17:50:36 fdrake Exp $"""
import os import os
import StringIO import StringIO
...@@ -129,16 +129,22 @@ class BDBStorage(BaseConfig): ...@@ -129,16 +129,22 @@ class BDBStorage(BaseConfig):
def open(self): def open(self):
from BDBStorage.BerkeleyBase import BerkeleyConfig from BDBStorage.BerkeleyBase import BerkeleyConfig
from BDBStorage.BDBFullStorage import BDBFullStorage storageclass = self.get_storageclass()
from BDBStorage.BDBMinimalStorage import BDBMinimalStorage
# Figure out which class we want
sectiontype = self.config.getSectionType()
storageclass = {'fullstorage': BDBFullStorage,
'minimalstorage': BDBMinimalStorage,
}[sectiontype]
bconf = BerkeleyConfig() bconf = BerkeleyConfig()
for name in dir(BerkeleyConfig): for name in dir(BerkeleyConfig):
if name.startswith('_'): if name.startswith('_'):
continue continue
setattr(bconf, name, getattr(self.config, name)) setattr(bconf, name, getattr(self.config, name))
return storageclass(self.config.name, config=bconf) return storageclass(self.config.name, config=bconf)
class BDBMinimalStorage(BDBStorage):
def get_storageclass(self):
import BDBStorage.BDBMinimalStorage
return BDBStorage.BDBMinimalStorage.BDBMinimalStorage
class BDBFullStorage(BDBStorage):
def get_storageclass(self):
import BDBStorage.BDBFullStorage
return BDBStorage.BDBFullStorage.BDBFullStorage
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment