[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/StartUp - ISimpleRegistry.py:1.2 RequestFactory.py:1.2 RequestFactoryRegistry.py:1.2 ServerType.py:1.2 ServerTypeRegistry.py:1.2 SimpleRegistry.py:1.2 SiteDefinition.py:1.2 __init__.py:1.2 configure.zcml:1.2 initZODB.py:1.2 meta.zcml:1.2 metaConfigure.py:1.2 startup.py:1.2
Jim Fulton
jim@zope.com
Tue, 19 Nov 2002 18:25:45 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/StartUp
In directory cvs.zope.org:/tmp/cvs-serv11465/lib/python/Zope/App/StartUp
Added Files:
ISimpleRegistry.py RequestFactory.py RequestFactoryRegistry.py
ServerType.py ServerTypeRegistry.py SimpleRegistry.py
SiteDefinition.py __init__.py configure.zcml initZODB.py
meta.zcml metaConfigure.py startup.py
Log Message:
Two changes that were far reaching and interdependent.
- Changed existing directives that mention interfaces to register
those interfaces with the global interface service.
- Moved all configuration support (except that in Zope.Configuration)
into Zope.App. This was necessary to get the order of execution such
that the interface service was defined before directives that used
interfaces were used. This is a change that has been needed for
some time.
=== Zope3/lib/python/Zope/App/StartUp/ISimpleRegistry.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/ISimpleRegistry.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+
+class ISimpleRegistry(Interface):
+ """
+ The Simple Registry is minimal collection of registered objects. This can
+ be useful, when it is expected that objects of a particular type are added
+ from many places in the system (through 3rd party products for example).
+
+ A good example for this are the Formulator fields. While the basic types
+ are defined inside the Formulator tree, other parties might add many
+ more later on in their products, so it is useful to provide a registry via
+ ZCML that allows to collect these items.
+
+ There is only one constraint on the objects. They all must implement a
+ particular interface specified during the initialization of the registry.
+
+ Note that it does not matter whether we have classes or instances as
+ objects. If the objects are instances, they must implement simply
+ IInstanceFactory.
+ """
+
+ def register(name, object):
+ """
+ Registers the object under the id name.
+ """
+
+
+ def getF(name):
+ """
+ This returns the object with id name.
+ """
=== Zope3/lib/python/Zope/App/StartUp/RequestFactory.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/RequestFactory.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""ctory.py,v 1.1.2.2 2002/04/02 02:20:40 srichter Exp $
+"""
+
+from Interface import Interface
+import copy
+
+
+class IRequestFactory(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.
+ """
+
+ def realize(db):
+ """Realize the factory by initalizing the publication.
+
+ The method returns the realized object.
+ """
+
+
+ def __call__(input_stream, output_steam, env):
+ """Call the Request Factory"""
+
+
+
+
+
+class RequestFactory:
+ """This class will generically create RequestFactories. This way I do
+ not have to create a method for each Server Type there is.
+ """
+
+ __implements__ = IRequestFactory
+
+ def __init__(self, publication, request):
+ """Initialize Request Factory"""
+ self._pubFactory = publication
+ self._publication = None
+ self._request = request
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.StartUp.RequestFactory.IRequestFactory
+
+ def realize(self, db):
+ 'See Zope.App.StartUp.RequestFactory.IRequestFactory'
+ realized = copy.copy(self)
+ realized._publication = realized._pubFactory(db)
+ return realized
+
+
+ def __call__(self, input_stream, output_steam, env):
+ 'See Zope.App.StartUp.RequestFactory.IRequestFactory'
+ request = self._request(input_stream, output_steam, env)
+ request.setPublication(self._publication)
+ return request
+
+ #
+ ############################################################
=== Zope3/lib/python/Zope/App/StartUp/RequestFactoryRegistry.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/RequestFactoryRegistry.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+$Id$
+"""
+from Zope.App.StartUp.SimpleRegistry import SimpleRegistry
+from Zope.App.StartUp.ISimpleRegistry import ISimpleRegistry
+from RequestFactory import IRequestFactory
+
+class IRequestFactoryRegistry(ISimpleRegistry):
+ """
+ The RequestFactory Registry manages a list of all the fields
+ available in Zope. A registry is useful at this point, since
+ fields can be initialized and registered by many places.
+
+ Note that it does not matter whether we have classes or instances as
+ fields. If the fields are instances, they must implement
+ IInstanceFactory.
+ """
+ pass
+
+
+class RequestFactoryRegistry(SimpleRegistry):
+ """ """
+ __implements__ = (IRequestFactoryRegistry,)
+
+
+
+RequestFactoryRegistry = RequestFactoryRegistry(IRequestFactory)
+registerRequestFactory = RequestFactoryRegistry.register
+getRequestFactory = RequestFactoryRegistry.get
=== Zope3/lib/python/Zope/App/StartUp/ServerType.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/ServerType.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""e.py,v 1.1.2.2 2002/04/02 02:20:40 srichter Exp $
+"""
+
+from Interface import Interface
+from RequestFactoryRegistry import getRequestFactory
+
+
+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.
+ """
+
+ def create(task_dispatcher, db, port=None, verbose=None):
+ """Create the server knowing the port, task dispatcher and the ZODB.
+ """
+
+
+class ServerType:
+
+ __implements__ = IServerType
+
+
+ def __init__(self, name, factory, requestFactory, logFactory,
+ defaultPort, defaultVerbose):
+ """ """
+ self._name = name
+ self._factory = factory
+ self._requestFactory = requestFactory
+ self._logFactory = logFactory
+ self._defaultPort = defaultPort
+ self._defaultVerbose = defaultVerbose
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.StartUp.ServerType.IServerType
+
+ def create(self, task_dispatcher, db, port=None, verbose=None):
+ 'See Zope.App.StartUp.ServerType.IServerType'
+
+ request_factory = getRequestFactory(self._requestFactory)
+ request_factory = request_factory.realize(db)
+
+ if port is None:
+ port = self._defaultPort
+
+ if verbose is None:
+ verbose = self._defaultVerbose
+
+ apply(self._factory,
+ (request_factory, self._name, '', port),
+ {'task_dispatcher': task_dispatcher,
+ 'verbose': verbose,
+ 'hit_log': self._logFactory()})
+
+ #
+ ############################################################
+
+
=== Zope3/lib/python/Zope/App/StartUp/ServerTypeRegistry.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/ServerTypeRegistry.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+$Id$
+"""
+from Zope.App.StartUp.SimpleRegistry import SimpleRegistry
+from Zope.App.StartUp.ISimpleRegistry import ISimpleRegistry
+from ServerType import IServerType
+
+class IServerTypeRegistry(ISimpleRegistry):
+ """
+ The ServerType Registry manages a list of all the fields
+ available in Zope. A registry is useful at this point, since
+ fields can be initialized and registered by many places.
+
+ Note that it does not matter whether we have classes or instances as
+ fields. If the fields are instances, they must implement
+ IInstanceFactory.
+ """
+ pass
+
+
+class ServerTypeRegistry(SimpleRegistry):
+ """Registry for the various Server types"""
+ __implements__ = (IServerTypeRegistry,)
+
+
+ServerTypeRegistry = ServerTypeRegistry(IServerType)
+registerServerType = ServerTypeRegistry.register
+getServerType = ServerTypeRegistry.get
=== Zope3/lib/python/Zope/App/StartUp/SimpleRegistry.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/SimpleRegistry.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,96 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+$Id$
+"""
+from Zope.Configuration.name import resolve
+from Zope.App.StartUp.ISimpleRegistry import ISimpleRegistry
+from types import StringTypes, ListType, TupleType
+ListTypes = (TupleType, ListType)
+
+
+class ZopeDuplicateRegistryEntryError(Exception):
+ """
+ This Error is raised when the user tries to add an object with
+ a name that already exists in the registry. Therefore,
+ overwriting is not allowed.
+ """
+
+ def __init__(self, name):
+ """Initializes Error"""
+ self.name = name
+
+ def __str__(self):
+ """Returns string representation of Error"""
+ return "The name '%s' is already defined in this registry." \
+ %self.name
+
+
+class ZopeIllegalInterfaceError(Exception):
+ """This Error is thrown, when the passed object does not implement
+ the specified interface."""
+
+ def __init__(self, name, interface):
+ """Initalize Error"""
+ self.name = name
+ self.interface = interface
+
+ def __str__(self):
+ """Returns string representation of Error"""
+ return ( "The object with name " + self.name + " does not implement "
+ "the interface " + self.interface.__name__ + "." )
+
+
+
+class SimpleRegistry:
+ """ """
+
+ __implements__ = (ISimpleRegistry,)
+
+
+ def __init__(self, interface):
+ """Initialize registry"""
+ self.objects = {}
+ self.interface = interface
+
+
+ def register(self, name, object):
+ '''See interface Zope.App.Formulator.ISimpleRegistry.ISimpleRegistry'''
+
+ if name in self.objects.keys():
+ raise ZopeDuplicateRegistryEntryError(name)
+
+ # XXX Find the right Interface tools to do that; unfortunately,
+ # I have not found them
+ # Check whether the object implements the right interface.
+ # Note, that we do *not* know whether the object is an instance
+ # or a class (or worse a Persistent class)
+ if hasattr(object, '__implements__') and \
+ ( self.interface == object.__implements__ or \
+ ( type(object.__implements__) in ListTypes and
+ self.interface in object.__implements__ ) ):
+ self.objects[name] = object
+
+ else:
+ raise ZopeIllegalInterfaceError(name, self.interface)
+
+ return []
+
+
+ def get(self, name):
+ '''See interface Zope.App.Formulator.ISimpleRegistry.ISimpleRegistry'''
+ if name in self.objects.keys():
+ return self.objects[name]
+ else:
+ return None
=== Zope3/lib/python/Zope/App/StartUp/SiteDefinition.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/SiteDefinition.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,170 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+This module handles the :startup directives.
+
+$Id$
+"""
+
+import sys
+
+# Import Configuration-related classes
+from Zope.Configuration.Action import Action
+from Zope.Configuration.INonEmptyDirective import INonEmptyDirective
+from Zope.Configuration.ISubdirectiveHandler import ISubdirectiveHandler
+
+from ServerTypeRegistry import getServerType
+
+# Import Undo-related classes
+from Zope.ComponentArchitecture import getService
+from Zope.App.Undo.ZODBUndoManager import ZODBUndoManager
+from Zope.App.Undo.IUndoManager import IUndoManager
+from Zope.App.OFS.Content.Folder.RootFolder import RootFolder
+from Zope.Server import ZLogIntegration
+from Zope.Server.TaskThreads import ThreadedTaskDispatcher
+from Zope.App.ZopePublication.ZopePublication import ZopePublication
+
+from Persistence.Module import PersistentModuleImporter
+
+import asyncore, zLOG
+
+DEFAULT_STORAGE_FILE = 'Data.fs'
+DEFAULT_LOG_FILE = 'STDERR'
+DEFAULT_LOG_CLASS = 'Zope.Server.HTTPServer.CommonHitLogger'
+
+
+class SiteDefinition:
+
+ __class_implements__ = INonEmptyDirective
+ __implements__ = ISubdirectiveHandler
+
+ # Some special file names for log files
+ _special_log_files = {'STDERR': sys.stderr,
+ 'STDOUT': sys.stdout}
+
+
+ def __init__(self, _context, name="default", threads=4):
+ """Initialize is called when defineSite directive is invoked."""
+ self._name = name
+ self._threads = int(threads)
+
+ self._zodb = None
+ self.useLog(_context)
+ self._servers = {}
+
+ self._started = 0
+
+
+ def useFileStorage(self, _context, file=DEFAULT_STORAGE_FILE):
+ """Lets you specify the ZODB to use."""
+ from ZODB.FileStorage import DB
+ self._zodb = DB(file)
+ return []
+
+
+ def useMappingStorage(self, _context):
+ """Lets you specify the ZODB to use."""
+ from ZODB.MappingStorage import DB
+ self._zodb = DB()
+ return []
+
+
+ def useLog(self, _context, file=DEFAULT_LOG_FILE):
+ """Lets you specify the log file to use"""
+
+ if file in self._special_log_files.keys():
+ file = self._special_log_files[file]
+ else:
+ file = open(file, 'a')
+
+ zLOG._set_log_dest(file)
+ return []
+
+
+ def addServer(self, _context, type, port=None, verbose=None):
+ """Add a new server for this site."""
+
+ if port is not None:
+ port = int(port)
+
+ if verbose is not None:
+ if verbose.lower() == 'true': verbose = 1
+ else: verbose = 0
+
+ if type is not None:
+ self._servers[type] = {'port': port,
+ 'verbose': verbose}
+ else:
+ sys.stderr.out('Warning: Server of Type %s does not exist. ' +
+ 'Directive neglected.')
+ return []
+
+
+ def start(self):
+ """Now start all the servers"""
+
+ sys.stderr.write('\nStarting Site: %s\n\n' %self._name)
+
+ sys.setcheckinterval(120)
+
+ # setup undo fnctionality
+ getService(None,"Utilities").provideUtility(
+ IUndoManager,
+ ZODBUndoManager(self._zodb)
+ )
+
+ # Setup the task dispatcher
+ td = ThreadedTaskDispatcher()
+ td.setThreadCount(self._threads)
+
+ # check whether a root was already specified for this ZODB; if
+ # not create one.
+ self._initDB()
+
+ # Start the servers
+ for type, server_info in self._servers.items():
+
+ server = getServerType(type)
+ server.create(td, self._zodb, server_info['port'],
+ server_info['verbose'])
+
+ def _initDB(self):
+ """Initialize the ZODB and persistence module importer."""
+
+ connection = self._zodb.open()
+ root = connection.root()
+ app = root.get(ZopePublication.root_name, None)
+
+ if app is None:
+
+ from Zope.App.OFS.Content.Folder.RootFolder import RootFolder
+ from Transaction import get_transaction
+
+ app = RootFolder()
+ root[ZopePublication.root_name] = app
+
+ get_transaction().commit()
+
+ connection.close()
+
+ imp = PersistentModuleImporter()
+ imp.install()
+
+
+ def __call__(self):
+ "Handle empty/simple declaration."
+ return [ Action(discriminator = 'Start Servers',
+ callable = self.start,
+ args = ()),
+ ]
=== Zope3/lib/python/Zope/App/StartUp/__init__.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/__init__.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,18 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
=== Zope3/lib/python/Zope/App/StartUp/configure.zcml 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/configure.zcml Tue Nov 19 18:25:14 2002
@@ -0,0 +1,54 @@
+<zopeConfigure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:startup="http://namespaces.zope.org/startup">
+
+
+ <startup:registerRequestFactory name="BrowserRequestFactory"
+ publication =
+ "Zope.App.ZopePublication.Browser.Publication.BrowserPublication"
+ request = "Zope.Publisher.Browser.BrowserRequest."
+ />
+
+
+ <startup:registerRequestFactory name="XMLRPCRequestFactory"
+ publication =
+ "Zope.App.ZopePublication.XMLRPC.Publication.XMLRPCPublication"
+ request = "Zope.Publisher.XMLRPC.XMLRPCRequest."
+ />
+
+
+ <startup:registerRequestFactory name="VFSRequestFactory"
+ publication =
+ "Zope.App.ZopePublication.VFS.Publication.VFSPublication"
+ request = "Zope.Publisher.VFS.VFSRequest."
+ />
+
+
+ <startup:registerServerType
+ name = "Browser"
+ factory = "Zope.Server.HTTP.PublisherHTTPServer."
+ requestFactory="BrowserRequestFactory"
+ logFactory = "Zope.Server.HTTP.CommonHitLogger."
+ defaultPort="8080"
+ defaultVerbose="true" />
+
+
+ <startup:registerServerType
+ name = "XML-RPC"
+ factory = "Zope.Server.HTTP.PublisherHTTPServer."
+ requestFactory="XMLRPCRequestFactory"
+ logFactory = "Zope.Server.HTTP.CommonHitLogger."
+ defaultPort="8081"
+ defaultVerbose="true" />
+
+
+ <startup:registerServerType
+ name = "FTP"
+ factory = "Zope.Server.FTP.PublisherFTPServer."
+ requestFactory="VFSRequestFactory"
+ logFactory = "Zope.Server.FTP.CommonFTPActivityLogger."
+ defaultPort="8021"
+ defaultVerbose="true" />
+
+
+</zopeConfigure>
=== Zope3/lib/python/Zope/App/StartUp/initZODB.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/initZODB.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,13 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
=== Zope3/lib/python/Zope/App/StartUp/meta.zcml 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/meta.zcml Tue Nov 19 18:25:14 2002
@@ -0,0 +1,33 @@
+<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+
+ <directives namespace="http://namespaces.zope.org/startup">
+
+ <directive name="defineSite"
+ attributes="name threads"
+ handler="Zope.App.StartUp.metaConfigure.defineSite">
+
+ <subdirective name="useFileStorage"
+ attributes="file" />
+
+ <subdirective name="useMappingStorage" />
+
+ <subdirective name="useLog" attributes="file" />
+
+ <subdirective name="addServer"
+ attributes="type port verbose logClass" />
+
+ </directive>
+
+ <directive name="registerRequestFactory"
+ attributes="name publication request"
+ handler="Zope.App.StartUp.metaConfigure.registerRequestFactory"
+ />
+
+ <directive name="registerServerType"
+ attributes="name publication request"
+ handler="Zope.App.StartUp.metaConfigure.registerServerType"
+ />
+
+ </directives>
+
+</zopeConfigure>
=== Zope3/lib/python/Zope/App/StartUp/metaConfigure.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/metaConfigure.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+This module handles the :startup directives.
+
+$Id$
+"""
+
+from SiteDefinition import SiteDefinition
+from Zope.Configuration.Action import Action
+from RequestFactory import RequestFactory
+import RequestFactoryRegistry
+from ServerType import ServerType
+import ServerTypeRegistry
+
+defineSite = SiteDefinition
+
+
+def registerRequestFactory(_context, name, publication, request):
+ """ """
+ publication = _context.resolve(publication)
+ request = _context.resolve(request)
+ request_factory = RequestFactory(publication, request)
+
+ return [
+ Action(
+ discriminator = name,
+ callable = RequestFactoryRegistry.registerRequestFactory,
+ 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 = 1
+ else:
+ defaultVerbose = 0
+
+ defaultPort = int(defaultPort)
+
+ server_type = ServerType(name, factory, requestFactory, logFactory,
+ defaultPort, defaultVerbose)
+
+
+ return [
+ Action(
+ discriminator = name,
+ callable = ServerTypeRegistry.registerServerType,
+ args = (name, server_type),
+ )
+ ]
+
=== Zope3/lib/python/Zope/App/StartUp/startup.py 1.1 => 1.2 ===
--- /dev/null Tue Nov 19 18:25:45 2002
+++ Zope3/lib/python/Zope/App/StartUp/startup.py Tue Nov 19 18:25:14 2002
@@ -0,0 +1,13 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################