Commit 3963e85d authored by Jim Fulton's avatar Jim Fulton

Bug Fixed: The runzeo script didn't work without a configuration file.

Simplified the file-storage configuration a bit.  Eliminated
duplication of defaults between the Python and ZConfig interfaces.
parent 406d75f1
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
Change History Change History
================ ================
3.9.0c1 (2009-08-06)
====================
Bugs Fixed
----------
- The runzeo script didn't work without a configuration file.
3.9.0b5 (2009-08-06) 3.9.0b5 (2009-08-06)
==================== ====================
......
...@@ -79,10 +79,7 @@ class ZEOOptionsMixin: ...@@ -79,10 +79,7 @@ class ZEOOptionsMixin:
def __init__(self, name, path): def __init__(self, name, path):
self._name = name self._name = name
self.path = path self.path = path
self.create = 0
self.read_only = 0
self.stop = None self.stop = None
self.quota = None
def getSectionName(self): def getSectionName(self):
return self._name return self._name
if not self.storages: if not self.storages:
...@@ -91,7 +88,12 @@ class ZEOOptionsMixin: ...@@ -91,7 +88,12 @@ class ZEOOptionsMixin:
conf = FileStorage(FSConfig(name, arg)) conf = FileStorage(FSConfig(name, arg))
self.storages.append(conf) self.storages.append(conf)
testing_exit_immediately = False
def handle_test(self, *args):
self.testing_exit_immediately = True
def add_zeo_options(self): def add_zeo_options(self):
self.add(None, None, None, "test", self.handle_test)
self.add(None, None, "a:", "address=", self.handle_address) self.add(None, None, "a:", "address=", self.handle_address)
self.add(None, None, "f:", "filename=", self.handle_filename) self.add(None, None, "f:", "filename=", self.handle_filename)
self.add("family", "zeo.address.family") self.add("family", "zeo.address.family")
...@@ -249,7 +251,10 @@ class ZEOServer: ...@@ -249,7 +251,10 @@ class ZEOServer:
self.server = create_server(self.storages, self.options) self.server = create_server(self.storages, self.options)
def loop_forever(self): def loop_forever(self):
asyncore.loop() if self.options.testing_exit_immediately:
print "testing exit immediately"
else:
asyncore.loop()
def handle_sigterm(self): def handle_sigterm(self):
log("terminated by SIGTERM") log("terminated by SIGTERM")
......
...@@ -33,6 +33,7 @@ import persistent ...@@ -33,6 +33,7 @@ import persistent
import shutil import shutil
import signal import signal
import stat import stat
import sys
import tempfile import tempfile
import threading import threading
import time import time
...@@ -1181,6 +1182,31 @@ def client_asyncore_thread_has_name(): ...@@ -1181,6 +1182,31 @@ def client_asyncore_thread_has_name():
1 1
""" """
def runzeo_without_configfile():
"""
>>> open('runzeo', 'w').write('''
... import sys
... sys.path[:] = %r
... import ZEO.runzeo
... ZEO.runzeo.main(sys.argv[1:])
... ''' % sys.path)
>>> import subprocess, re
>>> print re.sub('\d\d+|[:]', '', subprocess.Popen(
... [sys.executable, 'runzeo', '-a./s', '-ft', '--test'],
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
... ).stdout.read()),
------
--T INFO ZEO.runzeo () opening storage '1' using FileStorage
------
--T INFO ZEO.StorageServer () StorageServer created RW with storages 1RWt
------
--T INFO ZEO.zrpc () listening on ./s
------
--T INFO ZEO.runzeo () closing storage '1'
testing exit immediately
"""
slow_test_classes = [ slow_test_classes = [
BlobAdaptedFileStorageTests, BlobWritableCacheTests, BlobAdaptedFileStorageTests, BlobWritableCacheTests,
DemoStorageTests, FileStorageTests, MappingStorageTests, DemoStorageTests, FileStorageTests, MappingStorageTests,
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
use a BlobStorage to provide blob support.) use a BlobStorage to provide blob support.)
</description> </description>
</key> </key>
<key name="create" datatype="boolean" default="false"> <key name="create" datatype="boolean">
<description> <description>
Flag that indicates whether the storage should be truncated if Flag that indicates whether the storage should be truncated if
it already exists. it already exists.
</description> </description>
</key> </key>
<key name="read-only" datatype="boolean" default="false"> <key name="read-only" datatype="boolean">
<description> <description>
If true, only reads may be executed against the storage. Note If true, only reads may be executed against the storage. Note
that the "pack" operation is not considered a write operation that the "pack" operation is not considered a write operation
......
...@@ -154,19 +154,19 @@ class FileStorage(BaseConfig): ...@@ -154,19 +154,19 @@ class FileStorage(BaseConfig):
def open(self): def open(self):
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
config = self.config
options = {} options = {}
if self.config.packer: if getattr(config, 'packer', None):
m, name = self.config.packer.rsplit('.', 1) m, name = config.packer.rsplit('.', 1)
options['packer'] = getattr(__import__(m, {}, {}, ['*']), name) options['packer'] = getattr(__import__(m, {}, {}, ['*']), name)
return FileStorage(self.config.path, for name in ('blob_dir', 'create', 'read_only', 'quota', 'pack_gc',
create=self.config.create, 'pack_keep_old'):
read_only=self.config.read_only, v = getattr(config, name, self)
quota=self.config.quota, if v is not self:
pack_gc=self.config.pack_gc, options[name] = v
pack_keep_old=self.config.pack_keep_old,
blob_dir=self.config.blob_dir, return FileStorage(config.path, **options)
**options)
class BlobStorage(BaseConfig): class BlobStorage(BaseConfig):
......
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