[Zope3-checkins]
SVN: Zope3/branches/srichter-wsgi-zserver/src/zope/app/
Initial cut at the WSGI HTTP server implementation.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Apr 12 14:35:26 EDT 2005
Log message for revision 29952:
Initial cut at the WSGI HTTP server implementation.
Changed:
U Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/configure.zcml
A Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/wsgi.py
U Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/README.txt
U Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/__init__.py
-=-
Modified: Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/configure.zcml
===================================================================
--- Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/configure.zcml 2005-04-12 18:32:24 UTC (rev 29951)
+++ Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/configure.zcml 2005-04-12 18:35:25 UTC (rev 29952)
@@ -17,6 +17,12 @@
/>
<utility
+ name="WSGI-HTTP"
+ component=".wsgi.http"
+ provides=".servertype.IServerType"
+ />
+
+ <utility
name="FTP"
component=".ftp.server"
provides=".servertype.IServerType"
Added: Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/wsgi.py
===================================================================
--- Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/wsgi.py 2005-04-12 18:32:24 UTC (rev 29951)
+++ Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/wsgi.py 2005-04-12 18:35:25 UTC (rev 29952)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# 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.wsgihttpserver import WSGIHTTPServer
+
+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=''):
+ self._factory = factory
+ self._applicationFactory = applicationFactory
+ 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)
+
+ 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,
+ WSGIPublisherApplication,
+ CommonAccessLogger,
+ 8080, True)
Property changes on: Zope3/branches/srichter-wsgi-zserver/src/zope/app/server/wsgi.py
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/README.txt
===================================================================
--- Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/README.txt 2005-04-12 18:32:24 UTC (rev 29951)
+++ Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/README.txt 2005-04-12 18:35:25 UTC (rev 29952)
@@ -25,7 +25,7 @@
We can now initialize the application:
>>> from zope.app import wsgi
- >>> app = wsgi.PublisherApp(db)
+ >>> app = wsgi.WSGIPublisherApplication(db)
The callable ``app`` object accepts two positional arguments, the environment
and the function that initializes the response and returns a function with
Modified: Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/__init__.py
===================================================================
--- Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/__init__.py 2005-04-12 18:32:24 UTC (rev 29951)
+++ Zope3/branches/srichter-wsgi-zserver/src/zope/app/wsgi/__init__.py 2005-04-12 18:35:25 UTC (rev 29952)
@@ -77,7 +77,7 @@
self.wsgi_write(data)
-class PublisherApp(object):
+class WSGIPublisherApplication(object):
"""A WSGI application implemenation for the zope publisher
Instances of this class can be used as a WSGI application object.
@@ -105,8 +105,6 @@
publish(request)
- request.close()
-
# since the response is written using the WSGI ``write()`` callable
# return an empty iterable (see PEP 333).
return ""
More information about the Zope3-Checkins
mailing list