Commit 96f70233 authored by Chris McDonough's avatar Chris McDonough

Make /temp_folder a default database.

Import TemporaryFolder into zope schema so it can be specified in a config file.
parent 61d0b1d9
......@@ -16,7 +16,6 @@
import os
from ZODB.config import ZODBDatabase
from ZODB.config import FileStorage
# generic datatypes
......@@ -123,7 +122,7 @@ def root_config(section):
section.lock_filename = os.path.join(section.clienthome, 'Z2.lock')
if not section.databases:
section.databases = [getDefaultDatabaseFactory(section)]
section.databases = getDefaultDatabaseFactories(section)
mount_factories = {} # { name -> factory}
mount_points = {} # { virtual path -> name }
......@@ -196,31 +195,47 @@ class ZopeDatabase(ZODBDatabase):
return (real_root, real_path, self.container_class)
raise LookupError('Nothing known about mount path %s' % mount_path)
def getDefaultDatabaseFactory(context):
def getDefaultDatabaseFactories(context):
# default to a filestorage named 'Data.fs' in clienthome
# and a temporary storage for session data
from ZODB.Connection import Connection
from ZODB.config import FileStorage
from Products.TemporaryFolder.config import TemporaryStorage
l = []
class dummy:
def __init__(self, name):
def __init__(self, name, **kw):
self.name = name
for k, v in kw.items():
setattr(self, k, v)
def getSectionName(self):
return self.name
from ZODB.Connection import Connection
path = os.path.join(context.clienthome, 'Data.fs')
fs_ns = dummy('default filestorage at %s' % path)
fs_ns.path = path
fs_ns.create = None
fs_ns.read_only = None
fs_ns.quota = None
storage = FileStorage(fs_ns)
db_ns = dummy('main')
db_ns.storage = storage
db_ns.cache_size = 5000
db_ns.pool_size = 7
db_ns.version_pool_size=3
db_ns.version_cache_size = 100
db_ns.mount_points = ['/']
db_ns.connection_class = Connection
db_ns.class_factory = None
return ZopeDatabase(db_ns)
fs = dummy('default filestorage at %s' % path, path=path,
create=None, read_only=None, quota=None)
main = ZopeDatabase(dummy('main', storage=FileStorage(fs), cache_size=5000,
pool_size=7, version_pool_size=3,
version_cache_size=100, mount_points=['/'],
connection_class=Connection,
class_factory=None))
l.append(main)
ts = dummy('temporary storage for sessioning')
temporary = ZopeDatabase(dummy('temporary', storage=TemporaryStorage(ts),
cache_size=5000, pool_size=7,
version_pool_size=3, version_cache_size=100,
mount_points=['/temp_folder'],
connection_class=Connection,
class_factory=None))
temporary.container_class = ('Products.TemporaryFolder.TemporaryFolder.'
'SimpleTemporaryContainer')
l.append(temporary)
return l
......@@ -7,6 +7,7 @@
<import package="zLOG"/>
<import package="ZODB"/>
<import package="ZServer"/>
<import package="Products.TemporaryFolder"/>
<sectiontype name="logger" datatype=".LoggerFactory">
<description>
......
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