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