Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jim Fulton
committed
Dec 20, 2005
1 parent
2b6ebdb
commit f1801fc
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2005 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""WSGI-compliant HTTP server setup. | ||
$Id$ | ||
""" | ||
__docformat__ = "reStructuredText" | ||
|
||
import zope.interface | ||
from zope.server.http.commonaccesslogger import CommonAccessLogger | ||
from zope.server.http import wsgihttpserver | ||
|
||
from zope.app.publication.httpfactory import HTTPPublicationRequestFactory | ||
from zope.app.wsgi import WSGIPublisherApplication | ||
|
||
import servertype | ||
|
||
class ServerType(object): | ||
|
||
zope.interface.implements(servertype.IServerType) | ||
|
||
def __init__(self, factory, applicationFactory, logFactory, | ||
defaultPort, defaultVerbose, defaultIP='', | ||
requestFactory=HTTPPublicationRequestFactory): | ||
self._factory = factory | ||
self._applicationFactory = applicationFactory | ||
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, ip=None): | ||
'See IServerType' | ||
|
||
application = self._applicationFactory( | ||
db, factory=self._requestFactory) | ||
|
||
if port is None: | ||
port = self._defaultPort | ||
|
||
if ip is None: | ||
ip = self._defaultIP | ||
|
||
if verbose is None: | ||
verbose = self._defaultVerbose | ||
|
||
return self._factory(application, name, ip, port, | ||
task_dispatcher=task_dispatcher, | ||
verbose=verbose, | ||
hit_log=self._logFactory(), | ||
) | ||
|
||
|
||
http = ServerType(wsgihttpserver.WSGIHTTPServer, | ||
WSGIPublisherApplication, | ||
CommonAccessLogger, | ||
8080, True) | ||
|
||
pmhttp = ServerType(wsgihttpserver.PMDBWSGIHTTPServer, | ||
WSGIPublisherApplication, | ||
CommonAccessLogger, | ||
8013, True) |