[Zope3-checkins] CVS: Zope3/src/zope/app/process - metadirectives.py:1.1 configure.zcml:1.5 meta.zcml:1.4 metaconfigure.py:1.3 servertyperegistry.py:1.3
Stephan Richter
srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 12:35:29 -0400
Update of /cvs-repository/Zope3/src/zope/app/process
In directory cvs.zope.org:/tmp/cvs-serv29299
Modified Files:
configure.zcml meta.zcml metaconfigure.py
servertyperegistry.py
Added Files:
metadirectives.py
Log Message:
Converted yet another namespace, this time 'startup'
=== Added File Zope3/src/zope/app/process/metadirectives.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Schemas for the 'startup' ZCML Namespace
$Id: metadirectives.py,v 1.1 2003/08/02 16:34:53 srichter Exp $
"""
from zope.app.component.metaconfigure import handler
from zope.app.renderer.sourcetype import SourceTypes
from zope.configuration.fields import GlobalObject, Bool
from zope.interface import Interface
from zope.schema import TextLine, BytesLine, Int
class IBaseStartup(Interface):
"""Interface that specified common attributes of the startup
directives."""
publication = GlobalObject(
title=u"Publication",
description=u"Specifies the Publication component for which this " \
u"request is used.",
required=False)
request = GlobalObject(
title=u"Request",
description=u"Request component that is being instantiated.",
required=False)
class IRegisterRequestFactoryDirective(IBaseStartup):
"""Register a particular request factory that can be used by a server."""
name = TextLine(
title=u"Name",
description=u"Name of the request factory",
required=True)
factory = GlobalObject(
title=u"Factory",
description=u"If specified, this factory is used to create the" \
u"request.",
required=False)
class IRegisterServerTypeDirective(IBaseStartup):
"""Register a server type."""
name = TextLine(
title=u"Name",
description=u"Name as which the server will be known.",
required=True)
factory = GlobalObject(
title=u"Factory",
description=u"This factory is used to create the server component.",
required=True)
requestFactory = BytesLine(
title=u"Request Factory",
description=u"This is the factory id that is used to create the" \
u"request.",
required=True)
defaultPort = Int(
title=u"Default Port",
description=u"Start the server on this port, if no port is specified.",
required=True)
logFactory = GlobalObject(
title=u"Log Factory",
description=u"This factory is used to create the logging component.",
required=True)
defaultVerbose = Bool(
title=u"Default Verbose",
description=u"If not specifed, should the server start in verbose" \
u"mode.",
required=True)
=== Zope3/src/zope/app/process/configure.zcml 1.4 => 1.5 ===
--- Zope3/src/zope/app/process/configure.zcml:1.4 Thu Jul 3 15:37:36 2003
+++ Zope3/src/zope/app/process/configure.zcml Sat Aug 2 12:34:53 2003
@@ -1,87 +1,73 @@
-<zopeConfigure
+<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:startup="http://namespaces.zope.org/startup"
xmlns:event="http://namespaces.zope.org/event">
-
<startup:registerRequestFactory
- name="HTTPRequestFactory"
- factory="zope.app.publication.httpfactory"
- />
-
-
- <startup:registerRequestFactory name="BrowserRequestFactory"
- publication =
- "zope.app.publication.browser.BrowserPublication"
- request = "zope.publisher.browser.BrowserRequest"
- />
-
-
- <startup:registerRequestFactory name="XMLRPCRequestFactory"
- publication =
- "zope.app.publication.xmlrpc.XMLRPCPublication"
- request = "zope.publisher.xmlrpc.XMLRPCRequest"
- />
+ name="HTTPRequestFactory"
+ factory="zope.app.publication.httpfactory"/>
+ <startup:registerRequestFactory
+ name="BrowserRequestFactory"
+ publication="zope.app.publication.browser.BrowserPublication"
+ request="zope.publisher.browser.BrowserRequest" />
- <startup:registerRequestFactory name="FTPRequestFactory"
- publication = "zope.app.publication.ftp.FTPPublication"
- request = "zope.publisher.ftp.FTPRequest"
- />
+ <startup:registerRequestFactory
+ name="XMLRPCRequestFactory"
+ publication="zope.app.publication.xmlrpc.XMLRPCPublication"
+ request="zope.publisher.xmlrpc.XMLRPCRequest"/>
+ <startup:registerRequestFactory
+ name="FTPRequestFactory"
+ publication="zope.app.publication.ftp.FTPPublication"
+ request="zope.publisher.ftp.FTPRequest"/>
<startup:registerServerType
- name = "HTTP"
- factory = "zope.server.http.publisherhttpserver.PublisherHTTPServer"
- requestFactory="HTTPRequestFactory"
- logFactory = "zope.server.http.commonhitlogger.CommonHitLogger"
- defaultPort="8080"
- defaultVerbose="true" />
+ name="HTTP"
+ factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
+ requestFactory="HTTPRequestFactory"
+ logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
+ defaultPort="8080"
+ defaultVerbose="true" />
<startup:registerServerType
- name = "PostmortemDebuggingHTTP"
- factory = "zope.server.http.publisherhttpserver.PMDBHTTPServer"
- requestFactory="HTTPRequestFactory"
- logFactory = "zope.server.http.commonhitlogger.CommonHitLogger"
- defaultPort="8013"
- defaultVerbose="true" />
+ name="PostmortemDebuggingHTTP"
+ factory="zope.server.http.publisherhttpserver.PMDBHTTPServer"
+ requestFactory="HTTPRequestFactory"
+ logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
+ defaultPort="8013"
+ defaultVerbose="true" />
<startup:registerServerType
- name = "Browser"
- factory = "zope.server.http.publisherhttpserver.PublisherHTTPServer"
- requestFactory="BrowserRequestFactory"
- logFactory = "zope.server.http.commonhitlogger.CommonHitLogger"
- defaultPort="8080"
- defaultVerbose="true" />
-
+ name="Browser"
+ factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
+ requestFactory="BrowserRequestFactory"
+ logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
+ defaultPort="8080"
+ defaultVerbose="true" />
<startup:registerServerType
- name = "XML-RPC"
- factory = "zope.server.http.publisherhttpserver.PublisherHTTPServer"
- requestFactory="XMLRPCRequestFactory"
- logFactory = "zope.server.http.commonhitlogger.CommonHitLogger"
- defaultPort="8081"
- defaultVerbose="true" />
-
+ name="XML-RPC"
+ factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
+ requestFactory="XMLRPCRequestFactory"
+ logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
+ defaultPort="8081"
+ defaultVerbose="true" />
<startup:registerServerType
- name = "FTP"
- factory = "zope.server.ftp.publisher.PublisherFTPServer"
- requestFactory="FTPRequestFactory"
- logFactory = "zope.server.ftp.logger.CommonFTPActivityLogger"
- defaultPort="8021"
- defaultVerbose="true" />
-
+ name="FTP"
+ factory="zope.server.ftp.publisher.PublisherFTPServer"
+ requestFactory="FTPRequestFactory"
+ logFactory="zope.server.ftp.logger.CommonFTPActivityLogger"
+ defaultPort="8021"
+ defaultVerbose="true" />
<event:subscribe
- subscriber=".bootstrap.bootstrapInstance"
- event_types="zope.app.interfaces.event.IDatabaseOpenedEvent"
- />
-
+ subscriber=".bootstrap.bootstrapInstance"
+ event_types="zope.app.interfaces.event.IDatabaseOpenedEvent" />
<event:subscribe
- subscriber=".bootstrap.createInterfaceService"
- event_types="zope.app.interfaces.event.IDatabaseOpenedEvent"
- />
+ subscriber=".bootstrap.createInterfaceService"
+ event_types="zope.app.interfaces.event.IDatabaseOpenedEvent" />
-</zopeConfigure>
+</configure>
=== Zope3/src/zope/app/process/meta.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/process/meta.zcml:1.3 Mon Jul 28 18:21:19 2003
+++ Zope3/src/zope/app/process/meta.zcml Sat Aug 2 12:34:53 2003
@@ -1,18 +1,17 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta">
- <directives namespace="http://namespaces.zope.org/startup">
+ <meta:directive
+ name="registerRequestFactory"
+ namespace="http://namespaces.zope.org/startup"
+ schema=".metadirectives.IRegisterRequestFactoryDirective"
+ handler=".metaconfigure.registerRequestFactory" />
- <directive name="registerRequestFactory"
- attributes="name publication request factory"
- handler="zope.app.process.metaconfigure.registerRequestFactory"
- />
+ <meta:directive
+ name="registerServerType"
+ namespace="http://namespaces.zope.org/startup"
+ schema=".metadirectives.IRegisterServerTypeDirective"
+ handler=".metaconfigure.registerServerType"/>
- <directive name="registerServerType"
- attributes="name publication request factory requestFactory
- defaultPort logFactory defaultVerbose"
- handler="zope.app.process.metaconfigure.registerServerType"
- />
-
- </directives>
-
-</zopeConfigure>
+</configure>
=== Zope3/src/zope/app/process/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/process/metaconfigure.py:1.2 Wed Jun 25 11:29:32 2003
+++ Zope3/src/zope/app/process/metaconfigure.py Sat Aug 2 12:34:53 2003
@@ -11,13 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
-This module handles the :startup directives.
+"""This module handles the 'startup' ZCML namespace directives.
$Id$
"""
-
-from zope.configuration.action import Action
from zope.app.process import requestfactoryregistry
from zope.app.process import servertyperegistry
from zope.app.process.requestfactory import RequestFactory
@@ -30,43 +27,26 @@
if factory:
if request or publication:
raise ValuesError(
- """Can't provide a request or publication (factory) if you
+ """You cannot provide a request or publication (factory) if you
provide a (request) factory""")
- request_factory = _context.resolve(factory)
+ request_factory = factory
else:
- publication = _context.resolve(publication)
- request = _context.resolve(request)
request_factory = RequestFactory(publication, request)
- return [
- Action(
+ _context.action(
discriminator = name,
callable = requestfactoryregistry.registerRequestFactory,
- args = (name, request_factory,),
- )
- ]
+ args = (name, request_factory,) )
def registerServerType(_context, name, factory, requestFactory, logFactory,
defaultPort, defaultVerbose):
- factory = _context.resolve(factory)
- logFactory = _context.resolve(logFactory)
-
- if defaultVerbose.lower() == 'true':
- defaultVerbose = True
- else:
- defaultVerbose = False
-
- defaultPort = int(defaultPort)
server_type = ServerType(name, factory, requestFactory, logFactory,
defaultPort, defaultVerbose)
- return [
- Action(
+ _context.action(
discriminator = name,
callable = servertyperegistry.registerServerType,
- args = (name, server_type),
- )
- ]
+ args = (name, server_type) )
=== Zope3/src/zope/app/process/servertyperegistry.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/process/servertyperegistry.py:1.2 Wed Jun 25 11:29:32 2003
+++ Zope3/src/zope/app/process/servertyperegistry.py Sat Aug 2 12:34:53 2003
@@ -40,3 +40,8 @@
ServerTypeRegistry = ServerTypeRegistry(IServerType)
registerServerType = ServerTypeRegistry.register
getServerType = ServerTypeRegistry.get
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from zope.testing.cleanup import addCleanUp
+addCleanUp(ServerTypeRegistry._clear)
+del addCleanUp