Commit a893fc76 authored by Guido van Rossum's avatar Guido van Rossum

Refactor ZEOOptions into a reusable mixin and a ZEO-specific class.

parent 5ddbba39
...@@ -46,7 +46,7 @@ def parse_address(arg): ...@@ -46,7 +46,7 @@ def parse_address(arg):
obj = ZConfig.datatypes.SocketAddress(arg) obj = ZConfig.datatypes.SocketAddress(arg)
return obj.family, obj.address return obj.family, obj.address
class ZEOOptions(ZDOptions): class ZEOOptionsMixin:
storages = None storages = None
...@@ -74,13 +74,9 @@ class ZEOOptions(ZDOptions): ...@@ -74,13 +74,9 @@ class ZEOOptions(ZDOptions):
conf = FileStorage(FSConfig(name, arg)) conf = FileStorage(FSConfig(name, arg))
self.storages.append(conf) self.storages.append(conf)
def __init__(self): def add_zeo_options(self):
self.schemadir = os.path.dirname(__file__)
ZDOptions.__init__(self)
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("storages", "storages",
required="no storages specified; use -f or -C")
self.add("family", "zeo.address.family") self.add("family", "zeo.address.family")
self.add("address", "zeo.address.address", self.add("address", "zeo.address.address",
required="no server address specified; use -a or -C") required="no server address specified; use -a or -C")
...@@ -91,12 +87,6 @@ class ZEOOptions(ZDOptions): ...@@ -91,12 +87,6 @@ class ZEOOptions(ZDOptions):
self.add("monitor_address", None, "m:", "monitor=", self.add("monitor_address", None, "m:", "monitor=",
self.handle_monitor_address) self.handle_monitor_address)
def realize(self, *args):
ZDOptions.realize(self, *args)
if self.args:
self.usage("positional arguments are not supported")
self.load_logconf()
def load_logconf(self): def load_logconf(self):
if self.configroot.logger is not None: if self.configroot.logger is not None:
zLOG.set_initializer(self.log_initializer) zLOG.set_initializer(self.log_initializer)
...@@ -111,6 +101,21 @@ class ZEOOptions(ZDOptions): ...@@ -111,6 +101,21 @@ class ZEOOptions(ZDOptions):
EventLogger.event_logger.logger = logger EventLogger.event_logger.logger = logger
class ZEOOptions(ZDOptions, ZEOOptionsMixin):
def __init__(self):
self.schemadir = os.path.dirname(__file__)
ZDOptions.__init__(self)
self.add_zeo_options()
self.add("storages", "storages",
required="no storages specified; use -f or -C")
def realize(self, *args):
ZDOptions.realize(self, *args)
if self.configroot is not None:
self.load_logconf()
class ZEOServer: class ZEOServer:
def __init__(self, options): def __init__(self, options):
......
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