[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/server/ Added the
ability to specify a network interface to listen on.
Marius Gedminas
marius at pov.lt
Wed Feb 16 12:13:32 EST 2005
Log message for revision 29163:
Added the ability to specify a network interface to listen on.
Changed:
U Zope3/trunk/src/zope/app/server/servertype.py
U Zope3/trunk/src/zope/app/server/tests/test_servertype.py
-=-
Modified: Zope3/trunk/src/zope/app/server/servertype.py
===================================================================
--- Zope3/trunk/src/zope/app/server/servertype.py 2005-02-16 17:01:23 UTC (rev 29162)
+++ Zope3/trunk/src/zope/app/server/servertype.py 2005-02-16 17:13:31 UTC (rev 29163)
@@ -19,11 +19,13 @@
class IServerType(Interface):
- """This is a pure read-only interface, since the values are set through
- a ZCML directive and we shouldn't be able to change them.
+ """Server type utility.
+
+ This is a pure read-only interface, since the values are set through
+ a ZCML directive and we shouldn't be able to change them.
"""
- def create(name, task_dispatcher, db, port=None, verbose=None):
+ def create(name, task_dispatcher, db, port=None, verbose=None, ip=None):
"""Create the server knowing the port, task dispatcher and the ZODB.
Returns the new server.
@@ -34,15 +36,17 @@
implements(IServerType)
def __init__(self, factory, requestFactory, logFactory,
- defaultPort, defaultVerbose):
+ defaultPort, defaultVerbose, defaultIP=''):
self._factory = factory
self._requestFactory = requestFactory
self._logFactory = logFactory
self._defaultPort = defaultPort
self._defaultVerbose = defaultVerbose
+ self._defaultIP = defaultIP
- def create(self, name, task_dispatcher, db, port=None, verbose=None):
+ def create(self, name, task_dispatcher, db, port=None,
+ verbose=None, ip=None):
'See IServerType'
request_factory = self._requestFactory(db)
@@ -50,10 +54,13 @@
if port is None:
port = self._defaultPort
+ if ip is None:
+ ip = self._defaultIP
+
if verbose is None:
verbose = self._defaultVerbose
- return self._factory(request_factory, name, '', port,
+ return self._factory(request_factory, name, ip, port,
task_dispatcher=task_dispatcher,
verbose=verbose,
hit_log=self._logFactory(),
Modified: Zope3/trunk/src/zope/app/server/tests/test_servertype.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_servertype.py 2005-02-16 17:01:23 UTC (rev 29162)
+++ Zope3/trunk/src/zope/app/server/tests/test_servertype.py 2005-02-16 17:13:31 UTC (rev 29163)
@@ -67,6 +67,10 @@
The 'defaultVerbose' argument specifies the default verbosity.
+ The 'defaultIP' argument specifies the network interface for listening on.
+ You can specify the network interface IP address, or an empty string if you
+ want to listen on all interfaces.
+
>>> from zope.app.server.servertype import IServerType
>>> from zope.app.server.servertype import ServerType
>>> st = ServerType(factory, requestFactory, logFactory,
@@ -105,6 +109,14 @@
This server will be verbose
This server will be managed by my task dispatcher
+ >>> st.create('Sample Server 3', dispatcher, db, port=9090,
+ ... ip='127.0.0.1')
+ Starting a server (Sample Server 3) on 127.0.0.1:9090
+ This server will use my request factory for my database to construct requests
+ This server will use my logger for hit logging
+ This server will not be verbose
+ This server will be managed by my task dispatcher
+
"""
More information about the Zope3-Checkins
mailing list