[Zope3-checkins] SVN: Zope3/trunk/ Cleaned up startup, debugging and server-related module organization.

Jim Fulton jim at zope.com
Thu May 20 17:14:52 EDT 2004


Log message for revision 24843:
Cleaned up startup, debugging and server-related module organization.

Created a new zope.app.appsetup package that gas general application setup
code.  This started with code from zope.app._app, which is now gone.
Moved zope.app.process.bootstrap and zope.app.process.event here.

Moved the request-factory interfaces from zope.app.process to
zope.app.publication. 

Moved the rest of zope.app.process to zope.app.server.
zope.app.server is now a theoretically optional package.

Created a zope.app.debug package for the debugger with code from the
now-gone zope.app._app.




-=-
Modified: Zope3/trunk/doc/DEBUG.txt
===================================================================
--- Zope3/trunk/doc/DEBUG.txt	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/doc/DEBUG.txt	2004-05-20 21:14:51 UTC (rev 24843)
@@ -18,8 +18,8 @@
     zope application::
 
       $ python2.3
-      >>> from zope.app import Application
-      >>> app = Application('path/to/zodb/', 'path/to/site.zcml')
+      >>> from zope.app import Debugger
+      >>> debugger = Debugger('path/to/zodb/', 'path/to/site.zcml')
             
   Using the Debugger
 

Added: Zope3/trunk/package-includes/zope.app.server-configure.zcml
===================================================================
--- Zope3/trunk/package-includes/zope.app.server-configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/package-includes/zope.app.server-configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1 @@
+<include package="zope.app.server" />


Property changes on: Zope3/trunk/package-includes/zope.app.server-configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: Zope3/trunk/package-includes/zope.app.server-meta.zcml
===================================================================
--- Zope3/trunk/package-includes/zope.app.server-meta.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/package-includes/zope.app.server-meta.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1 @@
+<include package="zope.app.server" file="meta.zcml" />


Property changes on: Zope3/trunk/package-includes/zope.app.server-meta.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/PACKAGE.cfg	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/PACKAGE.cfg	2004-05-20 21:14:51 UTC (rev 24843)
@@ -71,7 +71,6 @@
 pagetemplate
 pluggableauth
 preview
-process
 publication
 publisher
 registration

Modified: Zope3/trunk/src/zope/app/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/__init__.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/__init__.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -11,8 +11,5 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
+"""Zope application package.
 """
-Zope application.
-"""
-
-from _app import config, Application

Deleted: Zope3/trunk/src/zope/app/_app.py
===================================================================
--- Zope3/trunk/src/zope/app/_app.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/_app.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,217 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Code to initialize the application server
-
-$Id$
-"""
-
-import base64, time
-from StringIO import StringIO
-from zope.publisher.publish import publish as _publish, debug_call
-from zope.publisher.browser import TestRequest
-from zope.app.publication.browser import BrowserPublication
-from zope.security.interfaces import IParticipation
-from zope.security.management import system_user
-from zope.interface import implements
-
-__metaclass__ = type
-
-
-class SystemConfigurationParticipation:
-    implements(IParticipation)
-
-    principal = system_user
-    interaction = None
-
-
-_configured = 0
-def config(file, execute=True):
-    "Configure site globals"
-    global _configured
-
-    if _configured:
-        return
-
-    from zope.configuration import xmlconfig
-
-    # Set user to system_user, so we can do anything we want
-    from zope.security.management import newInteraction
-    newInteraction(SystemConfigurationParticipation())
-
-    # Load server-independent site config
-    context = xmlconfig.file(file, execute=execute)
-
-    # Reset user
-    from zope.security.management import endInteraction
-    endInteraction()
-
-    _configured = execute
-
-    return context
-
-def database(db):
-    if type(db) is str:
-        # Database name
-        if db.endswith('.py'):
-            # Python source, exec it
-            globals = {}
-            execfile(db, globals)
-            if 'DB' in globals:
-                db = globals['DB']
-            else:
-                storage = globals['Storage']
-                from ZODB.DB import DB
-                db = DB(storage, cache_size=4000)
-        elif db.endswith(".fs"):
-            from ZODB.FileStorage import FileStorage
-            from ZODB.DB import DB
-            storage = FileStorage(db)
-            db = DB(storage, cache_size=4000)
-
-    # The following will fail unless the application has been configured.
-    from zope.app.process import event
-    from zope.app.event import publish
-    publish(None, event.DatabaseOpened(db))
-
-    return db
-
-class Application:
-
-    def __init__(self, db=None, config_file=None):
-        if db is None and config_file is None:
-            db = 'Data.fs'
-            config_file = 'site.zcml'
-
-        if config_file is not None:
-            config(config_file)
-        self.db = database(db)
-
-    def __call__(self):
-        """Get the top-level application object
-
-        The object returned is connected to an open database connection.
-        """
-
-        from zope.app.publication.zopepublication import ZopePublication
-        return self.db.open().root()[ZopePublication.root_name]
-
-    def _request(self,
-                 path='/', stdin='', stdout=None, basic=None,
-                 environment = None, form=None,
-                 request=TestRequest, publication=BrowserPublication):
-        """Create a request
-        """
-
-        env = {}
-
-        if stdout is None:
-            stdout = StringIO()
-
-        if type(stdin) is str:
-            stdin = StringIO(stdin)
-
-        p=path.split('?')
-        if len(p)==1:
-            env['PATH_INFO'] = p[0]
-        elif len(p)==2:
-            env['PATH_INFO'], env['QUERY_STRING'] = p
-        else:
-            raise ValueError("Too many ?s in path", path)
-
-        if environment is not None:
-            env.update(environment)
-
-        if basic:
-            env['HTTP_AUTHORIZATION']="Basic %s" % base64.encodestring(basic)
-
-
-        pub = publication(self.db)
-
-        request = request(stdin, stdout, env)
-        request.setPublication(pub)
-        if form:
-            # This requires that request class has an attribute 'form'
-            # (BrowserRequest has, TestRequest hasn't)
-            request.form.update(form)
-
-        return request
-
-    def publish(self, path='/', stdin='', stdout=None, *args, **kw):
-        t, c = time.time(), time.clock()
-
-        if stdout is None:
-            stdout = StringIO()
-
-        request = self._request(path, stdin, stdout, *args, **kw)
-        getStatus = getattr(request.response, 'getStatus', lambda: None)
-        _publish(request)
-        stdout.seek(0)
-        print stdout.read()
-        return time.time()-t, time.clock()-c, getStatus()
-
-    def run(self, *args, **kw):
-        t, c = time.time(), time.clock()
-        request = self._request(*args, **kw)
-        getStatus = getattr(request.response, 'getStatus', lambda: None)
-        _publish(request, handle_errors=False)
-        return time.time()-t, time.clock()-c, getStatus()
-
-    def debug(self, *args, **kw):
-
-        import pdb
-
-        class Pdb(pdb.Pdb):
-            def do_pub(self,arg):
-                if hasattr(self,'done_pub'):
-                    print 'pub already done.'
-                else:
-                    self.do_s('')
-                    self.do_s('')
-                    self.do_c('')
-                    self.done_pub=1
-            def do_ob(self,arg):
-                if hasattr(self,'done_ob'):
-                    print 'ob already done.'
-                else:
-                    self.do_pub('')
-                    self.do_c('')
-                    self.done_ob=1
-
-        db=Pdb()
-
-        request = self._request(*args, **kw)
-        fbreak(db, _publish)
-        fbreak(db, debug_call)
-
-        print '* Type c<cr> to jump to published object call.'
-        db.runcall(_publish, request)
-
-
-def fbreak(db, meth):
-    try:
-        meth = meth.im_func
-    except AttributeError:
-        pass
-    code = meth.func_code
-    lineno = getlineno(code)
-    filename = code.co_filename
-    db.set_break(filename,lineno)
-
-
-
-try:
-    from codehack import getlineno
-except:
-    def getlineno(code):
-        return code.co_firstlineno

Added: Zope3/trunk/src/zope/app/appsetup/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/__init__.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/appsetup/__init__.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,3 @@
+from zope.app.appsetup.appsetup import IDatabaseOpenedEvent, DatabaseOpened
+from zope.app.appsetup.appsetup import IProcessStartingEvent, ProcessStarting
+from zope.app.appsetup.appsetup import config, database


Property changes on: Zope3/trunk/src/zope/app/appsetup/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Copied: Zope3/trunk/src/zope/app/appsetup/appsetup.py (from rev 24841, Zope3/trunk/src/zope/app/_app.py)
===================================================================
--- Zope3/trunk/src/zope/app/_app.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/appsetup/appsetup.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,96 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Code to initialize the application server
+
+$Id$
+"""
+from zope.security.interfaces import IParticipation
+from zope.security.management import system_user
+from zope.app.event.interfaces import IEvent
+import zope.interface
+
+
+class IDatabaseOpenedEvent(IEvent):
+    """The main database has been opened."""
+
+    database = zope.interface.Attribute("The main database.")
+
+class DatabaseOpened:
+    zope.interface.implements(IDatabaseOpenedEvent)
+
+    def __init__(self, database):
+        self.database = database
+
+class IProcessStartingEvent(IEvent):
+    """The application server process is starting."""
+
+class ProcessStarting:
+    zope.interface.implements(IProcessStartingEvent)
+
+class SystemConfigurationParticipation:
+    zope.interface.implements(IParticipation)
+
+    principal = system_user
+    interaction = None
+
+
+_configured = 0
+def config(file, execute=True):
+    "Configure site globals"
+    global _configured
+
+    if _configured:
+        return
+
+    from zope.configuration import xmlconfig
+
+    # Set user to system_user, so we can do anything we want
+    from zope.security.management import newInteraction
+    newInteraction(SystemConfigurationParticipation())
+
+    # Load server-independent site config
+    context = xmlconfig.file(file, execute=execute)
+
+    # Reset user
+    from zope.security.management import endInteraction
+    endInteraction()
+
+    _configured = execute
+
+    return context
+
+def database(db):
+    if type(db) is str:
+        # Database name
+        if db.endswith('.py'):
+            # Python source, exec it
+            globals = {}
+            execfile(db, globals)
+            if 'DB' in globals:
+                db = globals['DB']
+            else:
+                storage = globals['Storage']
+                from ZODB.DB import DB
+                db = DB(storage, cache_size=4000)
+        elif db.endswith(".fs"):
+            from ZODB.FileStorage import FileStorage
+            from ZODB.DB import DB
+            storage = FileStorage(db)
+            db = DB(storage, cache_size=4000)
+
+    # The following will fail unless the application has been configured.
+    from zope.app.event import publish
+    publish(None, DatabaseOpened(db))
+
+    return db

Copied: Zope3/trunk/src/zope/app/appsetup/bootstrap.py (from rev 24841, Zope3/trunk/src/zope/app/process/bootstrap.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/bootstrap.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/appsetup/bootstrap.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,291 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Bootstrap code.
+
+This module contains code to bootstrap a Zope3 instance.  For example
+it makes sure a root folder exists and creates and configures some
+essential services.
+
+$Id$
+"""
+from transaction import get_transaction
+from zope.app.publication.zopepublication import ZopePublication
+from zope.interface import implements
+from zope.proxy import removeAllProxies
+from zope.component.exceptions import ComponentLookupError
+
+from zope.app import zapi
+from zope.app.event.interfaces import ISubscriber
+from zope.app.traversing import traverse, traverseName
+from zope.app.publication.zopepublication import ZopePublication
+from zope.app.folder import rootFolder
+from zope.app.servicenames import HubIds, PrincipalAnnotation
+from zope.app.servicenames import EventPublication, EventSubscription
+from zope.app.servicenames import ErrorLogging, Utilities
+from zope.app.site.service import ServiceManager, ServiceRegistration
+from zope.app.event.localservice import EventService
+from zope.app.errorservice import RootErrorReportingService
+from zope.app.event import function
+from zope.app.container.interfaces import INameChooser
+from zope.app.utility import UtilityRegistration, LocalUtilityService
+
+# XXX It should be possible to remove each of these from the basic
+# bootstrap, at which point we can remove the zope.app.hub,
+# zope.app.principalannotation, and zope.app.session packages from
+# zope.app.
+
+from zope.app.hub import ObjectHub, Registration
+from zope.app.hub.interfaces import ISubscriptionControl
+
+from zope.app.principalannotation import PrincipalAnnotationService
+
+from zope.app.session.interfaces import \
+     IBrowserIdManager, ISessionDataContainer
+from zope.app.session import \
+     CookieBrowserIdManager, PersistentSessionDataContainer
+
+class BootstrapSubscriberBase:
+    """A startup event subscriber base class.
+
+    Ensures the root folder and the service manager are created.
+    Subclasses may create local services by overriding the doSetup()
+    method.
+    """
+
+    implements(ISubscriber)
+
+    def doSetup(self):
+        """Instantiate some service.
+
+        This method is meant to be overriden in the subclasses.
+        """
+        pass
+
+    def notify(self, event):
+
+        db = event.database
+        connection = db.open()
+        root = connection.root()
+        self.root_folder = root.get(ZopePublication.root_name, None)
+        self.root_created = False
+
+        if self.root_folder is None:
+            self.root_created = True
+            # ugh... we depend on the root folder implementation
+            self.root_folder = rootFolder()
+            root[ZopePublication.root_name] = self.root_folder
+
+        try:
+            self.service_manager = traverse(self.root_folder, '++etc++site')
+        except ComponentLookupError:
+            self.service_manager = ServiceManager(self.root_folder)
+            self.root_folder.setSiteManager(self.service_manager)
+
+        self.doSetup()
+
+        get_transaction().commit()
+        connection.close()
+
+    def ensureObject(self, object_name, object_type, object_factory):
+        """Check that there's a basic object in the service
+        manager. If not, add one.
+
+        Return the name added, if we added an object, otherwise None.
+        """
+        package = getServiceManagerDefault(self.root_folder)
+        valid_objects = [ name
+                          for name in package
+                          if object_type.providedBy(package[name]) ]
+        if valid_objects:
+            return None
+        name = object_name
+        obj = object_factory()
+        obj = removeAllProxies(obj)
+        package[name] = obj
+        return name
+
+    def ensureService(self, service_type, service_factory, **kw):
+        """Add and configure a service to the root folder if it's
+        not yet provided.
+
+        Returns the name added or None if nothing was added.
+        """
+        if not self.service_manager.queryLocalService(service_type):
+            # The site-manager may have chosen to disable one of the
+            # core services. Their loss. The alternative is that when
+            # they restart, they get a new service of the one that 
+            # they chose to disable. 
+            reg = self.service_manager.queryRegistrations(service_type)
+            if reg is None:
+                return addConfigureService(self.root_folder, service_type,
+                                           service_factory, **kw)
+        else:
+            return None
+
+    def ensureUtility(
+            self, interface, utility_type, utility_factory, name='', **kw):
+        """Add a utility to the top Utility Service
+        
+        Returns the name added or None if nothing was added.
+        """
+        utility_manager = zapi.getService(
+                self.root_folder, Utilities
+                )
+        utility = utility_manager.queryUtility(interface, name=name)
+        if utility is None:
+            return addConfigureUtility(
+                    self.root_folder, interface, utility_type, utility_factory,
+                    name, **kw
+                    )
+        else:
+            return None
+
+
+class BootstrapInstance(BootstrapSubscriberBase):
+    """Bootstrap a Zope3 instance given a database object.
+
+    This first checks if the root folder exists and has a service
+    manager.  If it exists, nothing else is changed.  If no root
+    folder exists, one is added, and several essential services are
+    added and configured.
+    """
+
+    def doSetup(self):
+        """Add essential services.
+
+        XXX This ought to be configurable.  For now, hardcode some
+        services we know we all need.
+        """
+        # The EventService class implements two services
+        name = self.ensureService(EventPublication, EventService)
+        if name:
+            configureService(self.root_folder, EventSubscription, name)
+        elif not self.service_manager.queryLocalService(EventSubscription):
+            pub = self.service_manager.queryLocalService(EventPublication)
+            name = zapi.getName(pub)
+            configureService(self.root_folder, EventSubscription, name)
+
+        # Add the HubIds service, which subscribes itself to the event service
+        name = self.ensureService(HubIds, ObjectHub)
+        # Add a Registration object so that the Hub has something to do.
+        name = self.ensureObject('Registration',
+                                 ISubscriptionControl, Registration)
+
+        if name:
+            package = getServiceManagerDefault(self.root_folder)
+            reg = package[name]
+            # It's possible that we would want to reindex all objects when
+            # this is added - this seems like a very site-specific decision,
+            # though.
+            reg.subscribe()
+
+
+        # Sundry other services
+        self.ensureService(ErrorLogging,
+                           RootErrorReportingService, copy_to_zlog=True)
+        self.ensureService(PrincipalAnnotation, PrincipalAnnotationService)
+
+        self.ensureService(Utilities, LocalUtilityService)
+
+        # Utilities
+        self.ensureUtility(
+                IBrowserIdManager, 'CookieBrowserIdManager',
+                CookieBrowserIdManager,
+                )
+        self.ensureUtility(
+                ISessionDataContainer, 'PersistentSessionData',
+                PersistentSessionDataContainer, 'persistent'
+                )
+
+bootstrapInstance = BootstrapInstance()
+
+
+def addConfigureService(root_folder, service_type, service_factory, **kw):
+    """Add and configure a service to the root folder."""
+    name = addService(root_folder, service_type, service_factory, **kw)
+    configureService(root_folder, service_type, name)
+    return name
+
+def addService(root_folder, service_type, service_factory, **kw):
+    """Add a service to the root folder.
+
+    The service is added to the default package and activated.
+    This assumes the root folder already has a service manager,
+    and that we add at most one service of each type.
+
+    Returns the name of the service implementation in the default package.
+    """
+    # The code here is complicated by the fact that the registry
+    # calls at the end require a fully context-wrapped
+    # registration; hence all the traverse() and traverseName() calls.
+    package = getServiceManagerDefault(root_folder)
+    chooser = INameChooser(package)
+    service = service_factory()
+    service = removeAllProxies(service)
+    name = chooser.chooseName(service_type, service)
+    package[name] = service
+
+    # Set additional attributes on the service
+    for k, v in kw.iteritems():
+        setattr(service, k, v)
+    return name
+
+def configureService(root_folder, service_type, name, initial_status='Active'):
+    """Configure a service in the root folder."""
+    package = getServiceManagerDefault(root_folder)
+    registration_manager = package.getRegistrationManager()
+    registration =  ServiceRegistration(service_type,
+                                        name,
+                                        registration_manager)
+    key = registration_manager.addRegistration(registration)
+    registration = traverseName(registration_manager, key)
+    registration.status = initial_status
+
+def addConfigureUtility(
+        root_folder, interface, utility_type, utility_factory, name='', **kw):
+    """Add and configure a service to the root folder."""
+    folder_name = addUtility(root_folder, utility_type, utility_factory, **kw)
+    configureUtility(root_folder, interface, utility_type, name, folder_name)
+    return name
+
+def addUtility(root_folder, utility_type, utility_factory, **kw):
+    """ Add a Utility to the root folders Utility Service.
+
+    The utility is added to the default package and activated.
+    This assumes the root folder already as a Utility Service
+    """
+    package = getServiceManagerDefault(root_folder)
+    chooser = INameChooser(package)
+    utility = utility_factory()
+    name = chooser.chooseName(utility_type, utility)
+    package[name] = utility
+    # Set additional attributes on the utility
+    for k, v in kw.iteritems():
+        setattr(utility, k, v)
+    return name
+
+def configureUtility(
+        root_folder, interface, utility_type, name, folder_name,
+        initial_status='Active'):
+    """Configure a utility in the root folder."""
+    package = getServiceManagerDefault(root_folder)
+    registration_manager = package.getRegistrationManager()
+    registration = UtilityRegistration(name, interface, folder_name)
+    key = registration_manager.addRegistration(registration)
+    registration.status = initial_status
+
+def getServiceManagerDefault(root_folder):
+    package_name = '/++etc++site/default'
+    package = traverse(root_folder, package_name)
+    return package

Copied: Zope3/trunk/src/zope/app/appsetup/configure.zcml (from rev 24841, Zope3/trunk/src/zope/app/process/configure.zcml)
===================================================================
--- Zope3/trunk/src/zope/app/process/configure.zcml	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/appsetup/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,11 @@
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:event="http://namespaces.zope.org/event"
+   >
+
+  <event:subscribe
+      subscriber=".bootstrap.bootstrapInstance"
+      event_types="zope.app.appsetup.IDatabaseOpenedEvent"
+      />
+
+</configure>

Copied: Zope3/trunk/src/zope/app/appsetup/tests.py (from rev 24841, Zope3/trunk/src/zope/app/process/tests/test_bootstrap.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_bootstrap.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/appsetup/tests.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,192 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Bootstrap tests
+
+$Id$
+"""
+import unittest
+from transaction import get_transaction
+from ZODB.tests.util import DB
+from zope.exceptions import NotFoundError
+
+from zope.app.folder import rootFolder
+from zope.app.folder.interfaces import IRootFolder
+from zope.app.errorservice.interfaces import IErrorReportingService
+from zope.app.principalannotation.interfaces import IPrincipalAnnotationService
+from zope.app.event.interfaces import IEventService
+from zope.app.hub.interfaces import IObjectHub
+from zope.app.publication.zopepublication import ZopePublication
+from zope.app.site.tests.placefulsetup import PlacefulSetup
+from zope.app.errorservice import ErrorReportingService
+from zope.app.servicenames import ErrorLogging
+from zope.app.traversing import traverse
+from zope.app.site.service import ServiceManager
+
+class EventStub(object):
+
+    def __init__(self, db):
+        self.database = db
+
+
+class TestBootstrapSubscriberBase(PlacefulSetup, unittest.TestCase):
+
+    def setUp(self):
+        PlacefulSetup.setUp(self)
+        self.db = DB()
+
+    def tearDown(self):
+        PlacefulSetup.tearDown(self)
+        self.db.close()
+
+    def createRootFolder(self):
+        cx = self.db.open()
+        root = cx.root()
+        self.root_folder = rootFolder()
+        root[ZopePublication.root_name] = self.root_folder
+        get_transaction().commit()
+        cx.close()
+
+    def createRFAndSM(self):
+        cx = self.db.open()
+        root = cx.root()
+        self.root_folder = rootFolder()
+        root[ZopePublication.root_name] = self.root_folder
+        self.service_manager = ServiceManager(self.root_folder)
+        self.root_folder.setSiteManager(self.service_manager)
+        get_transaction().commit()
+        cx.close()
+
+
+    def test_notify(self):
+        from zope.app.appsetup.bootstrap import BootstrapSubscriberBase
+
+        for setup in (lambda: None), self.createRootFolder, self.createRFAndSM:
+
+            setup()
+
+            BootstrapSubscriberBase().notify(EventStub(self.db))
+
+            cx = self.db.open()
+            root = cx.root()
+            root_folder = root.get(ZopePublication.root_name, None)
+            self.assert_(IRootFolder.providedBy(root_folder))
+
+            package_name = '/++etc++site/default'
+            package = traverse(root_folder, package_name)
+
+            cx.close()
+
+    def test_ensureService(self):
+        from zope.app.appsetup.bootstrap import BootstrapSubscriberBase
+
+        self.createRFAndSM()
+        bs = BootstrapSubscriberBase()
+        bs.notify(EventStub(self.db))
+        for i in range(2):
+            cx = self.db.open()
+            name = bs.ensureService(ErrorLogging, ErrorReportingService)
+
+            if i == 0:
+                self.assertEqual(name, 'ErrorLogging')
+            else:
+                self.assertEqual(name, None)
+
+            root = cx.root()
+            root_folder = root[ZopePublication.root_name]
+
+            package_name = '/++etc++site/default'
+            package = traverse(root_folder, package_name)
+
+            self.assert_(IErrorReportingService.providedBy(
+                traverse(package, 'ErrorLogging')))
+            get_transaction().commit()
+            cx.close()
+
+class TestBootstrapInstance(TestBootstrapSubscriberBase):
+
+    def test_bootstrapInstance(self):
+        from zope.app.appsetup.bootstrap import bootstrapInstance
+
+        bootstrapInstance.notify(EventStub(self.db))
+
+        cx = self.db.open()
+        root = cx.root()
+        root_folder = root[ZopePublication.root_name]
+
+        package_name = '/++etc++site/default'
+        package = traverse(root_folder, package_name)
+
+        self.assert_(IEventService.providedBy(
+            traverse(package, 'EventPublication')))
+
+        self.assert_(IObjectHub.providedBy(
+            traverse(package, 'HubIds')))
+
+        self.assert_(IErrorReportingService.providedBy(
+            traverse(package, 'ErrorLogging')))
+
+        self.assert_(IPrincipalAnnotationService.providedBy(
+            traverse(package, 'PrincipalAnnotation')))
+
+        cx.close()
+
+    def test_bootstrapInstance_withServices(self):
+        from zope.app.appsetup.bootstrap import bootstrapInstance
+        from zope.app.appsetup.bootstrap import addService, configureService
+
+        self.createRFAndSM()
+
+        name = addService(self.root_folder, 'Errors',
+                          ErrorReportingService, copy_to_zlog=True)
+        configureService(self.root_folder, ErrorLogging, name)
+
+        bootstrapInstance.notify(EventStub(self.db))
+
+        cx = self.db.open()
+        root = cx.root()
+        root_folder = root[ZopePublication.root_name]
+
+        package_name = '/++etc++site/default'
+        package = traverse(root_folder, package_name)
+
+        self.assert_(IEventService.providedBy(
+            traverse(package, 'EventPublication')))
+
+        self.assert_(IObjectHub.providedBy(
+            traverse(package, 'HubIds')))
+
+        self.assertRaises(NotFoundError, traverse, root_folder,
+                          '/++etc++site/default/ErrorLogging')
+
+        self.assert_(IErrorReportingService.providedBy(
+            traverse(package, 'Errors')))
+
+        self.assert_(IEventService.providedBy(
+            traverse(package, 'EventPublication')))
+
+        self.assert_(IPrincipalAnnotationService.providedBy(
+            traverse(package, 'PrincipalAnnotation')))
+
+        cx.close()
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestBootstrapSubscriberBase))
+    suite.addTest(unittest.makeSuite(TestBootstrapInstance))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()

Modified: Zope3/trunk/src/zope/app/broken/broken.py
===================================================================
--- Zope3/trunk/src/zope/app/broken/broken.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/broken/broken.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -77,7 +77,7 @@
     database-opened event::
 
       >>> import ZODB.tests.util
-      >>> from zope.app.process.event import DatabaseOpened
+      >>> from zope.app.appsetup import DatabaseOpened
       >>> db = ZODB.tests.util.DB()
       >>> installBroken(DatabaseOpened(db))
     

Modified: Zope3/trunk/src/zope/app/broken/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/broken/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/broken/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -9,7 +9,7 @@
 
   <event:subscribe
       subscriber=".broken.installBrokenSubscriber"
-      event_types="zope.app.event.interfaces.IDatabaseOpenedEvent" 
+      event_types="zope.app.appsetup.IDatabaseOpenedEvent" 
       />
 
   <include file="browser.zcml" /> 

Modified: Zope3/trunk/src/zope/app/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -20,7 +20,6 @@
   <include package="zope.app.observable" />
   <include package="zope.app.annotation" />
   <include package="zope.app.dependable" />
-  <include package="zope.app.server" />
   
   <include file="menus.zcml" />
 
@@ -70,10 +69,10 @@
   <include package="zope.app.broken" />
 
 
-  <!-- Process-configuration support -->
-  <include package="zope.app.process" />
+  <!-- Database boostrapping -->
+  <include package=".appsetup" />
+  
 
-
   <!-- Skins -->
 
   <include package="zope.app.basicskin" />

Added: Zope3/trunk/src/zope/app/debug/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/debug/__init__.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/debug/__init__.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1 @@
+from zope.app.debug.debug import Debugger


Property changes on: Zope3/trunk/src/zope/app/debug/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Copied: Zope3/trunk/src/zope/app/debug/debug.py (from rev 24841, Zope3/trunk/src/zope/app/_app.py)
===================================================================
--- Zope3/trunk/src/zope/app/_app.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/debug/debug.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,154 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Code to initialize the application server
+
+$Id$
+"""
+
+import base64, time
+from StringIO import StringIO
+from zope.publisher.publish import publish as _publish, debug_call
+from zope.publisher.browser import TestRequest
+from zope.app.publication.browser import BrowserPublication
+from zope.app.appsetup import config, database
+
+class Debugger(object):
+
+    def __init__(self, db=None, config_file=None):
+        if db is None and config_file is None:
+            db = 'Data.fs'
+            config_file = 'site.zcml'
+
+        if config_file is not None:
+            config(config_file)
+        self.db = database(db)
+
+    def root(self):
+        """Get the top-level application object
+
+        The object returned is connected to an open database connection.
+        """
+
+        from zope.app.publication.zopepublication import ZopePublication
+        return self.db.open().root()[ZopePublication.root_name]
+
+    def _request(self,
+                 path='/', stdin='', stdout=None, basic=None,
+                 environment = None, form=None,
+                 request=TestRequest, publication=BrowserPublication):
+        """Create a request
+        """
+
+        env = {}
+
+        if stdout is None:
+            stdout = StringIO()
+
+        if type(stdin) is str:
+            stdin = StringIO(stdin)
+
+        p=path.split('?')
+        if len(p)==1:
+            env['PATH_INFO'] = p[0]
+        elif len(p)==2:
+            env['PATH_INFO'], env['QUERY_STRING'] = p
+        else:
+            raise ValueError("Too many ?s in path", path)
+
+        if environment is not None:
+            env.update(environment)
+
+        if basic:
+            env['HTTP_AUTHORIZATION']="Basic %s" % base64.encodestring(basic)
+
+
+        pub = publication(self.db)
+
+        request = request(stdin, stdout, env)
+        request.setPublication(pub)
+        if form:
+            # This requires that request class has an attribute 'form'
+            # (BrowserRequest has, TestRequest hasn't)
+            request.form.update(form)
+
+        return request
+
+    def publish(self, path='/', stdin='', stdout=None, *args, **kw):
+        t, c = time.time(), time.clock()
+
+        if stdout is None:
+            stdout = StringIO()
+
+        request = self._request(path, stdin, stdout, *args, **kw)
+        getStatus = getattr(request.response, 'getStatus', lambda: None)
+        _publish(request)
+        stdout.seek(0)
+        print stdout.read()
+        return time.time()-t, time.clock()-c, getStatus()
+
+    def run(self, *args, **kw):
+        t, c = time.time(), time.clock()
+        request = self._request(*args, **kw)
+        getStatus = getattr(request.response, 'getStatus', lambda: None)
+        _publish(request, handle_errors=False)
+        return time.time()-t, time.clock()-c, getStatus()
+
+    def debug(self, *args, **kw):
+
+        import pdb
+
+        class Pdb(pdb.Pdb):
+            def do_pub(self,arg):
+                if hasattr(self,'done_pub'):
+                    print 'pub already done.'
+                else:
+                    self.do_s('')
+                    self.do_s('')
+                    self.do_c('')
+                    self.done_pub=1
+            def do_ob(self,arg):
+                if hasattr(self,'done_ob'):
+                    print 'ob already done.'
+                else:
+                    self.do_pub('')
+                    self.do_c('')
+                    self.done_ob=1
+
+        db=Pdb()
+
+        request = self._request(*args, **kw)
+        fbreak(db, _publish)
+        fbreak(db, debug_call)
+
+        print '* Type c<cr> to jump to published object call.'
+        db.runcall(_publish, request)
+
+
+def fbreak(db, meth):
+    try:
+        meth = meth.im_func
+    except AttributeError:
+        pass
+    code = meth.func_code
+    lineno = getlineno(code)
+    filename = code.co_filename
+    db.set_break(filename,lineno)
+
+
+
+try:
+    from codehack import getlineno
+except:
+    def getlineno(code):
+        return code.co_firstlineno

Modified: Zope3/trunk/src/zope/app/event/function.py
===================================================================
--- Zope3/trunk/src/zope/app/event/function.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/event/function.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -38,7 +38,7 @@
 
         <event:subscribe
             subscriber='.module.startupEventHandler'
-            event_types='zope.app.event.interfaces.IProcessStartingEvent'
+            event_types='zope.app.appsetup.IProcessStartingEvent'
             />
     """
     implements(ISubscriber)

Modified: Zope3/trunk/src/zope/app/event/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/event/interfaces.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/event/interfaces.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -338,11 +338,3 @@
 
 class IObjectContentModifiedEvent(IObjectModifiedEvent):
     """An object's content has been modified"""
-
-class IDatabaseOpenedEvent(IEvent):
-    """The main database has been opened."""
-
-    database = Attribute("The main database.")
-
-class IProcessStartingEvent(IEvent):
-    """The application server process is starting."""

Modified: Zope3/trunk/src/zope/app/generations/subscriber.zcml
===================================================================
--- Zope3/trunk/src/zope/app/generations/subscriber.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/generations/subscriber.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -3,7 +3,7 @@
 <!--
 <subscribe
     subscriber=".generations.evolveSubscriber"
-    event_types="zope.app.event.interfaces.IDatabaseOpenedEvent" 
+    event_types="zope.app.appsetup.IDatabaseOpenedEvent" 
     >
     Evolve to current generation on startup
 </subscribe>
@@ -12,7 +12,7 @@
 <!--
 <subscribe
     subscriber=".generations.evolveNotSubscriber"
-    event_types="zope.app.event.interfaces.IDatabaseOpenedEvent" 
+    event_types="zope.app.appsetup.IDatabaseOpenedEvent" 
     >
     Don't evolve, but check for minimum generations on startup
 </subscribe>
@@ -20,7 +20,7 @@
 
 <subscribe
     subscriber=".generations.evolveMinimumSubscriber"
-    event_types="zope.app.event.interfaces.IDatabaseOpenedEvent" 
+    event_types="zope.app.appsetup.IDatabaseOpenedEvent" 
     >
     Only evolve to minimum generations on startup
 </subscribe>

Modified: Zope3/trunk/src/zope/app/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/meta.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/meta.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -10,7 +10,6 @@
 <include package="zope.app.form.browser" file="meta.zcml" />
 <include package="zope.app.event" file="meta.zcml" />
 <include package="zope.app.i18n" file="meta.zcml" />
-<include package="zope.app.process" file="meta.zcml" />
 <include package="zope.app.pagetemplate" file="meta.zcml" />
 <include package="zope.app.fssync" file="meta.zcml" />
 <include package="zope.app.schema" file="meta.zcml" />

Modified: Zope3/trunk/src/zope/app/module/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/module/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/module/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -28,7 +28,7 @@
   <!-- Enable import of persistent modules -->
   <event:subscribe
       subscriber=".installPersistentModuleImporter"
-      event_types="zope.app.event.interfaces.IProcessStartingEvent"
+      event_types="zope.app.appsetup.IProcessStartingEvent"
       />
 
   <include package=".browser" />

Deleted: Zope3/trunk/src/zope/app/process/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/process/__init__.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/__init__.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1 +0,0 @@
-# Make this a package.

Deleted: Zope3/trunk/src/zope/app/process/bootstrap.py
===================================================================
--- Zope3/trunk/src/zope/app/process/bootstrap.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/bootstrap.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,290 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Bootstrap code.
-
-This module contains code to bootstrap a Zope3 instance.  For example
-it makes sure a root folder exists and creates and configures some
-essential services.
-
-$Id$
-"""
-from transaction import get_transaction
-from zope.interface import implements
-from zope.proxy import removeAllProxies
-from zope.component.exceptions import ComponentLookupError
-
-from zope.app import zapi
-from zope.app.event.interfaces import ISubscriber
-from zope.app.traversing import traverse, traverseName
-from zope.app.publication.zopepublication import ZopePublication
-from zope.app.folder import rootFolder
-from zope.app.servicenames import HubIds, PrincipalAnnotation
-from zope.app.servicenames import EventPublication, EventSubscription
-from zope.app.servicenames import ErrorLogging, Utilities
-from zope.app.site.service import ServiceManager, ServiceRegistration
-from zope.app.event.localservice import EventService
-from zope.app.errorservice import RootErrorReportingService
-from zope.app.event import function
-from zope.app.container.interfaces import INameChooser
-from zope.app.utility import UtilityRegistration, LocalUtilityService
-
-# XXX It should be possible to remove each of these from the basic
-# bootstrap, at which point we can remove the zope.app.hub,
-# zope.app.principalannotation, and zope.app.session packages from
-# zope.app.
-
-from zope.app.hub import ObjectHub, Registration
-from zope.app.hub.interfaces import ISubscriptionControl
-
-from zope.app.principalannotation import PrincipalAnnotationService
-
-from zope.app.session.interfaces import \
-     IBrowserIdManager, ISessionDataContainer
-from zope.app.session import \
-     CookieBrowserIdManager, PersistentSessionDataContainer
-
-class BootstrapSubscriberBase:
-    """A startup event subscriber base class.
-
-    Ensures the root folder and the service manager are created.
-    Subclasses may create local services by overriding the doSetup()
-    method.
-    """
-
-    implements(ISubscriber)
-
-    def doSetup(self):
-        """Instantiate some service.
-
-        This method is meant to be overriden in the subclasses.
-        """
-        pass
-
-    def notify(self, event):
-
-        db = event.database
-        connection = db.open()
-        root = connection.root()
-        self.root_folder = root.get(ZopePublication.root_name, None)
-        self.root_created = False
-
-        if self.root_folder is None:
-            self.root_created = True
-            # ugh... we depend on the root folder implementation
-            self.root_folder = rootFolder()
-            root[ZopePublication.root_name] = self.root_folder
-
-        try:
-            self.service_manager = traverse(self.root_folder, '++etc++site')
-        except ComponentLookupError:
-            self.service_manager = ServiceManager(self.root_folder)
-            self.root_folder.setSiteManager(self.service_manager)
-
-        self.doSetup()
-
-        get_transaction().commit()
-        connection.close()
-
-    def ensureObject(self, object_name, object_type, object_factory):
-        """Check that there's a basic object in the service
-        manager. If not, add one.
-
-        Return the name added, if we added an object, otherwise None.
-        """
-        package = getServiceManagerDefault(self.root_folder)
-        valid_objects = [ name
-                          for name in package
-                          if object_type.providedBy(package[name]) ]
-        if valid_objects:
-            return None
-        name = object_name
-        obj = object_factory()
-        obj = removeAllProxies(obj)
-        package[name] = obj
-        return name
-
-    def ensureService(self, service_type, service_factory, **kw):
-        """Add and configure a service to the root folder if it's
-        not yet provided.
-
-        Returns the name added or None if nothing was added.
-        """
-        if not self.service_manager.queryLocalService(service_type):
-            # The site-manager may have chosen to disable one of the
-            # core services. Their loss. The alternative is that when
-            # they restart, they get a new service of the one that 
-            # they chose to disable. 
-            reg = self.service_manager.queryRegistrations(service_type)
-            if reg is None:
-                return addConfigureService(self.root_folder, service_type,
-                                           service_factory, **kw)
-        else:
-            return None
-
-    def ensureUtility(
-            self, interface, utility_type, utility_factory, name='', **kw):
-        """Add a utility to the top Utility Service
-        
-        Returns the name added or None if nothing was added.
-        """
-        utility_manager = zapi.getService(
-                self.root_folder, Utilities
-                )
-        utility = utility_manager.queryUtility(interface, name=name)
-        if utility is None:
-            return addConfigureUtility(
-                    self.root_folder, interface, utility_type, utility_factory,
-                    name, **kw
-                    )
-        else:
-            return None
-
-
-class BootstrapInstance(BootstrapSubscriberBase):
-    """Bootstrap a Zope3 instance given a database object.
-
-    This first checks if the root folder exists and has a service
-    manager.  If it exists, nothing else is changed.  If no root
-    folder exists, one is added, and several essential services are
-    added and configured.
-    """
-
-    def doSetup(self):
-        """Add essential services.
-
-        XXX This ought to be configurable.  For now, hardcode some
-        services we know we all need.
-        """
-
-        # The EventService class implements two services
-        name = self.ensureService(EventPublication, EventService)
-        if name:
-            configureService(self.root_folder, EventSubscription, name)
-        elif not self.service_manager.queryLocalService(EventSubscription):
-            pub = self.service_manager.queryLocalService(EventPublication)
-            name = zapi.getName(pub)
-            configureService(self.root_folder, EventSubscription, name)
-
-        # Add the HubIds service, which subscribes itself to the event service
-        name = self.ensureService(HubIds, ObjectHub)
-        # Add a Registration object so that the Hub has something to do.
-        name = self.ensureObject('Registration',
-                                 ISubscriptionControl, Registration)
-        if name:
-            package = getServiceManagerDefault(self.root_folder)
-            reg = package[name]
-            # It's possible that we would want to reindex all objects when
-            # this is added - this seems like a very site-specific decision,
-            # though.
-            reg.subscribe()
-
-
-        # Sundry other services
-        self.ensureService(ErrorLogging,
-                           RootErrorReportingService, copy_to_zlog=True)
-        self.ensureService(PrincipalAnnotation, PrincipalAnnotationService)
-
-        self.ensureService(Utilities, LocalUtilityService)
-
-        # Utilities
-        self.ensureUtility(
-                IBrowserIdManager, 'CookieBrowserIdManager',
-                CookieBrowserIdManager,
-                )
-        self.ensureUtility(
-                ISessionDataContainer, 'PersistentSessionData',
-                PersistentSessionDataContainer, 'persistent'
-                )
-
-bootstrapInstance = BootstrapInstance()
-
-
-def addConfigureService(root_folder, service_type, service_factory, **kw):
-    """Add and configure a service to the root folder."""
-    name = addService(root_folder, service_type, service_factory, **kw)
-    configureService(root_folder, service_type, name)
-    return name
-
-def addService(root_folder, service_type, service_factory, **kw):
-    """Add a service to the root folder.
-
-    The service is added to the default package and activated.
-    This assumes the root folder already has a service manager,
-    and that we add at most one service of each type.
-
-    Returns the name of the service implementation in the default package.
-    """
-    # The code here is complicated by the fact that the registry
-    # calls at the end require a fully context-wrapped
-    # registration; hence all the traverse() and traverseName() calls.
-    package = getServiceManagerDefault(root_folder)
-    chooser = INameChooser(package)
-    service = service_factory()
-    service = removeAllProxies(service)
-    name = chooser.chooseName(service_type, service)
-    package[name] = service
-
-    # Set additional attributes on the service
-    for k, v in kw.iteritems():
-        setattr(service, k, v)
-    return name
-
-def configureService(root_folder, service_type, name, initial_status='Active'):
-    """Configure a service in the root folder."""
-    package = getServiceManagerDefault(root_folder)
-    registration_manager = package.getRegistrationManager()
-    registration =  ServiceRegistration(service_type,
-                                        name,
-                                        registration_manager)
-    key = registration_manager.addRegistration(registration)
-    registration = traverseName(registration_manager, key)
-    registration.status = initial_status
-
-def addConfigureUtility(
-        root_folder, interface, utility_type, utility_factory, name='', **kw):
-    """Add and configure a service to the root folder."""
-    folder_name = addUtility(root_folder, utility_type, utility_factory, **kw)
-    configureUtility(root_folder, interface, utility_type, name, folder_name)
-    return name
-
-def addUtility(root_folder, utility_type, utility_factory, **kw):
-    """ Add a Utility to the root folders Utility Service.
-
-    The utility is added to the default package and activated.
-    This assumes the root folder already as a Utility Service
-    """
-    package = getServiceManagerDefault(root_folder)
-    chooser = INameChooser(package)
-    utility = utility_factory()
-    name = chooser.chooseName(utility_type, utility)
-    package[name] = utility
-    # Set additional attributes on the utility
-    for k, v in kw.iteritems():
-        setattr(utility, k, v)
-    return name
-
-def configureUtility(
-        root_folder, interface, utility_type, name, folder_name,
-        initial_status='Active'):
-    """Configure a utility in the root folder."""
-    package = getServiceManagerDefault(root_folder)
-    registration_manager = package.getRegistrationManager()
-    registration = UtilityRegistration(name, interface, folder_name)
-    key = registration_manager.addRegistration(registration)
-    registration.status = initial_status
-
-def getServiceManagerDefault(root_folder):
-    package_name = '/++etc++site/default'
-    package = traverse(root_folder, package_name)
-    return package

Deleted: Zope3/trunk/src/zope/app/process/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/process/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,71 +0,0 @@
-<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"/>
-
-  <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" />
-
-  <startup:registerServerType 
-      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" />
-
-  <startup:registerServerType 
-      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" />
-
-  <event:subscribe
-      subscriber=".bootstrap.bootstrapInstance"
-      event_types="zope.app.event.interfaces.IDatabaseOpenedEvent"
-      />
-
-</configure>

Deleted: Zope3/trunk/src/zope/app/process/event.py
===================================================================
--- Zope3/trunk/src/zope/app/process/event.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/event.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,30 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Process-lifetime related events.
-
-$Id$
-"""
-
-from zope.interface import implements
-from zope.app.event.interfaces import \
-     IDatabaseOpenedEvent, IProcessStartingEvent
-
-class DatabaseOpened:
-    implements(IDatabaseOpenedEvent)
-
-    def __init__(self, database):
-        self.database = database
-
-class ProcessStarting:
-    implements(IProcessStartingEvent)

Deleted: Zope3/trunk/src/zope/app/process/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/process/interfaces.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/interfaces.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Interfaces for the zope.app.process package.
-
-$Id$
-"""
-
-from zope.interface import Interface
-
-
-class IPublicationRequestFactoryFactory(Interface):
-    """Publication request factory factory"""
-
-    def realize(db):
-        """Create a publication and request factory for a given database
-
-        Return a IPublicationRequestFactory for the given database.
-        """
-
-
-class IPublicationRequestFactory(Interface):
-    """Publication request factory"""
-
-    def __call__(input_stream, output_steam, env):
-        """Create a request object to handle the given inputs
-
-        A request is created and configured with a publication object.
-        """
-
-
-class IRequestFactory(IPublicationRequestFactory,
-                      IPublicationRequestFactoryFactory):
-    """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.
-    """
-
-
-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."""

Deleted: Zope3/trunk/src/zope/app/process/main.py
===================================================================
--- Zope3/trunk/src/zope/app/process/main.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/main.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,101 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Functions that control how the Zope appserver knits itself together.
-
-$Id$
-"""
-
-import logging
-import os
-import sys
-import time
-
-from zdaemon import zdoptions
-
-import ThreadedAsync
-
-from zope.app import config
-from zope.app.event import publish
-from zope.app.process import event
-from zope.server.taskthreads import ThreadedTaskDispatcher
-
-CONFIG_FILENAME = "zope.conf"
-
-
-class ZopeOptions(zdoptions.ZDOptions):
-
-    logsectionname = None
-
-    def default_configfile(self):
-        dir = os.path.normpath(
-            os.path.join(os.path.dirname(__file__),
-                         os.pardir, os.pardir, os.pardir, os.pardir))
-        for filename in [CONFIG_FILENAME, CONFIG_FILENAME + ".in"]:
-            filename = os.path.join(dir, filename)
-            if os.path.isfile(filename):
-                return filename
-        return None
-
-
-def main(args=None):
-    # Record start times (real time and CPU time)
-    t0 = time.time()
-    c0 = time.clock()
-
-    setup(args)
-
-    t1 = time.time()
-    c1 = time.clock()
-    logging.info("Startup time: %.3f sec real, %.3f sec CPU", t1-t0, c1-c0)
-
-    run()
-    sys.exit(0)
-
-
-def run():
-    try:
-        ThreadedAsync.loop()
-    except KeyboardInterrupt:
-        # Exit without spewing an exception.
-        pass
-
-
-def setup(args=None):
-    if args is None:
-        args = sys.argv[1:]
-    options = ZopeOptions()
-    options.schemadir = os.path.dirname(os.path.abspath(__file__))
-    options.realize(args)
-    options = options.configroot
-
-    if options.path:
-        sys.path[:0] = [os.path.abspath(p) for p in options.path]
-
-    sys.setcheckinterval(options.check_interval)
-
-    options.eventlog()
-
-    config(options.site_definition)
-
-    db = options.database.open()
-
-    publish(None, event.DatabaseOpened(db))
-
-    task_dispatcher = ThreadedTaskDispatcher()
-    task_dispatcher.setThreadCount(options.threads)
-
-    for server in options.servers:
-        server.create(task_dispatcher, db)
-
-    publish(None, event.ProcessStarting())

Deleted: Zope3/trunk/src/zope/app/process/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/process/meta.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/meta.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,17 +0,0 @@
-<configure 
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <meta:directive 
-      name="registerRequestFactory"
-      namespace="http://namespaces.zope.org/startup"
-      schema=".metadirectives.IRegisterRequestFactoryDirective"
-      handler=".metaconfigure.registerRequestFactory" />
-
-  <meta:directive 
-      name="registerServerType"
-      namespace="http://namespaces.zope.org/startup"
-      schema=".metadirectives.IRegisterServerTypeDirective"
-      handler=".metaconfigure.registerServerType"/>
-
-</configure>

Deleted: Zope3/trunk/src/zope/app/process/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/process/metaconfigure.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/metaconfigure.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# 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' ZCML namespace directives.
-
-$Id$
-"""
-from zope.app.process import requestfactoryregistry
-from zope.app.process import servertyperegistry
-from zope.app.process.requestfactory import RequestFactory
-from zope.app.process.servertype import ServerType
-
-
-def registerRequestFactory(_context, name, request=None, publication=None,
-                           factory=None):
-
-    if factory:
-        if request or publication:
-            raise ValuesError(
-                """You cannot provide a request or publication (factory) if you
-                provide a (request) factory""")
-        request_factory = factory
-
-    else:
-        request_factory = RequestFactory(publication, request)
-
-    _context.action(
-            discriminator = name,
-            callable = requestfactoryregistry.registerRequestFactory,
-            args = (name, request_factory,) )
-
-
-def registerServerType(_context, name, factory, requestFactory, logFactory,
-                       defaultPort, defaultVerbose):
-
-    server_type = ServerType(name, factory, requestFactory, logFactory,
-                             defaultPort, defaultVerbose)
-
-    _context.action(
-            discriminator = name,
-            callable = servertyperegistry.registerServerType,
-            args = (name, server_type) )

Deleted: Zope3/trunk/src/zope/app/process/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/process/metadirectives.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/metadirectives.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,87 +0,0 @@
-##############################################################################
-#
-# 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$
-"""
-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)

Deleted: Zope3/trunk/src/zope/app/process/mkzopeinstance.py
===================================================================
--- Zope3/trunk/src/zope/app/process/mkzopeinstance.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/mkzopeinstance.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,188 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 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.
-#
-##############################################################################
-"""Implementation of the mkzopeinstance script.
-
-This creates a new instances of the Zope server instance home.  An
-'instance home' contains two things:
-
-- application server configuration and data
-
-- server process control scripts and data
-
-$Id$
-"""
-import optparse
-import os
-import shutil
-import sys
-
-import zope
-
-from zope.app.applicationcontrol import zopeversion
-
-
-def main(argv=None):
-    """Top-level script function to create a new Zope instance."""
-    if argv is None:
-        argv = sys.argv
-    try:
-        options = parse_args(argv)
-    except SystemExit, e:
-        if e.code:
-            return 2
-        else:
-            return 0
-    app = Application(options)
-    return app.process()
-
-
-class Application:
-
-    def __init__(self, options):
-        self.options = options
-
-    def read_input_line(self, prompt):
-        # The tests replace this to make sure the right things happen.
-        return raw_input(prompt)
-
-    def process(self):
-        options = self.options
-
-        # make sure we can find the skeleton
-        if not os.path.isdir(options.skeleton):
-            print >>sys.stderr, "skeleton directory", options.skeleton
-            print >>sys.stderr, "does not exist or is not a directory"
-            return 1
-
-        # create the destination
-        if not options.destination:
-            options.destination = self.get_skeltarget()
-        options.destination = os.path.abspath(options.destination)
-        if not os.path.exists(options.destination):
-            try:
-                os.mkdir(options.destination)
-            except OSError, e:
-                print >>sys.stderr, "could not create instance home:", e
-                return 1
-        elif not os.path.isdir(options.destination):
-            print >>sys.stderr, options.destination, "is not a directory"
-            print >>sys.stderr, ("(instance homes cannot be created in"
-                                 " non-directories)")
-            return 1
-
-        # XXX for now, bail if the username/password hasn't been
-        # provided from the command line; this should be improved
-        # after the ZopeX3 alpha:
-        if not (options.username and options.password):
-            print >>sys.stderr, ("username and password must be"
-                                 " provided using the --user option")
-            return 2
-
-        # now create the instance!
-        self.copy_skeleton()
-        return 0
-
-    def get_skeltarget(self):
-        print SKELTARGET_MESSAGE
-        while 1:
-            skeltarget = self.read_input_line("Directory: ").strip()
-            if skeltarget == '':
-                print >>sys.stderr, 'You must specify a directory'
-                continue
-            else:
-                break
-        return os.path.expanduser(skeltarget)
-
-    def copy_skeleton(self):
-        options = self.options
-        # XXX we should be able to compute the script
-        script = os.path.abspath(sys.argv[0])
-        zope_home = os.path.dirname(os.path.dirname(script))
-        zope_init = os.path.abspath(zope.__file__)
-        software_home = os.path.dirname(os.path.dirname(zope_init))
-        self.replacements = [
-            ("<<USERNAME>>",      options.username),
-            ("<<PASSWORD>>",      options.password),
-            ("<<PYTHON>>",        sys.executable),
-            ("<<INSTANCE_HOME>>", options.destination),
-            ("<<ZOPE_HOME>>",     zope_home),
-            ("<<SOFTWARE_HOME>>", software_home),
-            ]
-        self.copytree(self.options.skeleton, self.options.destination)
-
-    def copytree(self, src, dst):
-        # Similar to shutil.copytree(), but doesn't care about
-        # symlinks, doesn't collect errors, and uses self.copyfile()
-        # instead of shutil.copy2().
-        assert os.path.isdir(dst), dst
-        names = os.listdir(src)
-        for name in names:
-            srcname = os.path.join(src, name)
-            dstname = os.path.join(dst, name)
-            if os.path.isdir(srcname):
-                os.mkdir(dstname)
-                self.copytree(srcname, dstname)
-            else:
-                self.copyfile(srcname, dstname)
-            # XXX What about devices, sockets etc.?
-
-    def copyfile(self, src, dst):
-        if dst.endswith(".in"):
-            dst = dst[:-3]
-            text = open(src, "rU").read()
-            # perform replacements
-            for var, string in self.replacements:
-                text = text.replace(var, string)
-            f = open(dst, "w")
-            f.write(text)
-            f.close()
-            shutil.copymode(src, dst)
-            shutil.copystat(src, dst)
-        else:
-            shutil.copy2(src, dst)
-
-
-SKELTARGET_MESSAGE = """\
-Please choose a directory in which you'd like to install Zope
-'instance home' files such as database files, configuration files,
-etc.
-"""
-
-
-def parse_args(argv):
-    """Parse the command line, returning an object representing the input."""
-    path, prog = os.path.split(os.path.realpath(argv[0]))
-    basedir = os.path.dirname(path)
-    # no assurance that this exists!
-    default_skeleton = os.path.join(basedir, "skel")
-    version = "%prog for " + zopeversion.ZopeVersionUtility.getZopeVersion()
-    p = optparse.OptionParser(prog=prog,
-                              usage="%prog [options]",
-                              version=version)
-    p.add_option("-d", "--dir", dest="destination", metavar="DIR",
-                 help="the dir in which the instance home should be created")
-    p.add_option("-s", "--skelsrc", dest="skeleton", metavar="DIR",
-                 default=default_skeleton,
-                 help="template skeleton directory")
-    p.add_option("-u", "--user", dest="username", metavar="USER:PASSWORD",
-                 help="set the user name and password of the initial user")
-    options, args = p.parse_args(argv[1:])
-    options.program = prog
-    options.version = version
-    if args:
-        p.error("too many arguments")
-    options.password = None
-    if options.username and ":" in options.username:
-        options.username, options.password = options.username.split(":", 1)
-    return options

Deleted: Zope3/trunk/src/zope/app/process/refactor.txt
===================================================================
--- Zope3/trunk/src/zope/app/process/refactor.txt	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/refactor.txt	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,18 +0,0 @@
-The code here and in zope._app is more complicated than it needs to be.
-
-Here's what I want to do:
-
-- Move the definition of request and server factories to Python
-
-- Register the server factories (aka server types) as utilities.
-  
-
-These let us rip out most of the code here. :)
-
-Move the rest of the code here to zope.app.server.  The
-zope.app.server package is just tha zope.app. customization of
-zope.server.
-
-Rename zope._app to zope.app.debug. Move the config function from
-zope.app.debug into zope.app.setup.  Move the bootstrap code to
-zope.app.setup.

Deleted: Zope3/trunk/src/zope/app/process/requestfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/process/requestfactory.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/requestfactory.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,47 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Request Factory
-
-$Id$
-"""
-import copy
-from zope.app.process.interfaces import IRequestFactory
-from zope.interface import implements
-
-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
-
-
-    def realize(self, db):
-        'See IRequestFactory'
-        realized = copy.copy(self)
-        realized._publication = realized._pubFactory(db)
-        return realized
-
-
-    def __call__(self, input_stream, output_steam, env):
-        'See IRequestFactory'
-        request = self._request(input_stream, output_steam, env)
-        request.setPublication(self._publication)
-        return request

Deleted: Zope3/trunk/src/zope/app/process/requestfactoryregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/requestfactoryregistry.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/requestfactoryregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# 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.interface import implements
-from zope.app.process.interfaces import ISimpleRegistry
-from zope.app.process.interfaces import IPublicationRequestFactoryFactory
-from zope.app.process.simpleregistry import SimpleRegistry
-
-
-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.
-    """
-
-
-class RequestFactoryRegistry(SimpleRegistry):
-    implements(IRequestFactoryRegistry)
-
-
-RequestFactoryRegistry = RequestFactoryRegistry(
-    IPublicationRequestFactoryFactory)
-
-registerRequestFactory = RequestFactoryRegistry.register
-getRequestFactory = RequestFactoryRegistry.get
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(RequestFactoryRegistry._clear)
-del addCleanUp

Deleted: Zope3/trunk/src/zope/app/process/schema.xml
===================================================================
--- Zope3/trunk/src/zope/app/process/schema.xml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/schema.xml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,81 +0,0 @@
-<schema>
-  <description>
-    Zope 3 configuration schema.
-
-    This schema describes the configuration options available to a
-    site administrator via the zope.conf configuration file.
-  </description>
-
-  <!-- database and storage types -->
-  <import package="ZODB" />
-
-  <!-- logging configuration -->
-  <import package="ZConfig.components.logger" />
-
-  <sectiontype name="server" datatype="zope.app.process.server.ServerFactory">
-    <key name="type" required="yes" />
-    <key name="address" datatype="inet-address" />
-    <key name="verbose" datatype="boolean" />
-  </sectiontype>
-
-  <section type="ZODB.database" name="*" required="yes"
-           attribute="database">
-    <description>
-      The main application database that should be used.
-    </description>
-  </section>
-
-  <section type="eventlog" attribute="eventlog" name="*">
-    <description>
-      Configuration for the event log.
-    </description>
-  </section>
-
-  <multisection type="server" name="*" attribute="servers" />
-
-  <key name="site-definition" default="site.zcml">
-    <description>
-      The name of the top-level ZCML file that defines the component
-      configuration used for this site.
-    </description>
-  </key>
-
-  <key name="interrupt-check-interval" datatype="integer" default="120"
-       attribute="check_interval">
-    <description>
-      Value passed to Python's sys.setcheckinterval() function.
-
-      This integer value determines how often the interpreter checks
-      for periodic things such as thread switches and signal handlers.
-      Setting it to a larger value may increase performance for
-      programs using threads.  Setting it to a value &lt;= 0 checks every
-      virtual instruction, maximizing responsiveness as well as
-      overhead.
-    </description>
-  </key>
-
-  <key name="threads" datatype="integer" default="4">
-    <description>
-      The number of threads which should be used to serve requests.
-
-      The threads are placed in a pool and are used to serve requests
-      received from the servers configured using &lt;server&gt;
-      sections.  This does not constrain the total number of threads
-      used by the application server; additional threads may be used
-      for internal purposes.
-    </description>
-  </key>
-
-  <multikey name="path" datatype="string">
-    <description>
-      This specifies additional paths directories which are inserted into
-      the beginning of Python's module search path.  The set of directories
-      specified is inserted into the beginning of the module search path in
-      the order which they are specified here.  Note that the processing of
-      this directive may happen too late under some circumstances; it is
-      recommended that you use the PYTHONPATH environment variable if
-      using this directive doesn't work for you.
-    </description>
-    <metadefault>$softwarehome/src</metadefault>
-  </multikey>
-</schema>

Deleted: Zope3/trunk/src/zope/app/process/server.py
===================================================================
--- Zope3/trunk/src/zope/app/process/server.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/server.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-
-"""Datatype for a <server> section in a Zope 3 configuration file.
-
-This is called by the ZConfig machinery while processing a configuration.
-
-$Id$
-"""
-
-from zope.app.process.servertyperegistry import getServerType
-
-
-class ServerFactory:
-    """Factory for server objects.
-
-    The factories are part of the configuration data returned by
-    ZConfig.
-    """
-
-    def __init__(self, section):
-        """Initialize the factory based on a <server> section."""
-        self.type = section.type
-        self.address = section.address
-        self.verbose = section.verbose
-
-    def create(self, task_dispatcher, database):
-        """Return a server based on the server types defined via ZCML."""
-        servertype = getServerType(self.type)
-        # The server object self-registers with the asyncore mainloop.
-        servertype.create(task_dispatcher, database,
-                          self.address[1], # XXX maybe improve API
-                          self.verbose)

Deleted: Zope3/trunk/src/zope/app/process/servertype.py
===================================================================
--- Zope3/trunk/src/zope/app/process/servertype.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/servertype.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,61 +0,0 @@
-##############################################################################
-#
-# 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 zope.interface import Interface, implements
-from zope.app.process.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
-
-
-    def create(self, task_dispatcher, db, port=None, verbose=None):
-        'See 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()})

Deleted: Zope3/trunk/src/zope/app/process/servertyperegistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/servertyperegistry.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/servertyperegistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,47 +0,0 @@
-##############################################################################
-#
-# 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.process.interfaces import ISimpleRegistry
-from zope.app.process.servertype import IServerType
-from zope.app.process.simpleregistry import SimpleRegistry
-from zope.interface import implements
-
-
-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.
-    """
-
-
-class ServerTypeRegistry(SimpleRegistry):
-    """Registry for the various Server types"""
-    implements(IServerTypeRegistry)
-
-
-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

Deleted: Zope3/trunk/src/zope/app/process/simpleregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/simpleregistry.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/process/simpleregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,86 +0,0 @@
-##############################################################################
-#
-# 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.process.interfaces import ISimpleRegistry
-from zope.interface import implements
-
-ListTypes = (tuple, list)
-
-
-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.getName() + ".")
-
-
-class SimpleRegistry:
-    """ """
-
-    implements(ISimpleRegistry)
-
-    def __init__(self, interface):
-        """Initialize registry"""
-        self.objects = {}
-        self.interface = interface
-
-    def _clear(self):
-        self.objects.clear()
-
-    def register(self, name, object):
-        '''See ISimpleRegistry'''
-
-        if name in self.objects.keys():
-            raise ZopeDuplicateRegistryEntryError(name)
-
-        if self.interface.providedBy(object):
-            self.objects[name] = object
-        else:
-            raise ZopeIllegalInterfaceError(name, self.interface)
-
-        return []
-
-    def get(self, name):
-        '''See ISimpleRegistry'''
-        if name in self.objects.keys():
-            return self.objects[name]
-        else:
-            return None

Modified: Zope3/trunk/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -20,8 +20,8 @@
 from zope.publisher.browser import BrowserRequest
 from zope.publisher.xmlrpc import XMLRPCRequest
 
-from zope.app.process.interfaces import IPublicationRequestFactoryFactory
-from zope.app.process.interfaces import IPublicationRequestFactory
+from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
+from zope.app.publication.interfaces import IPublicationRequestFactory
 
 from zope.app.publication.http import HTTPPublication
 from zope.app.publication.browser import BrowserPublication
@@ -37,13 +37,13 @@
     implements(IPublicationRequestFactory)
 
     def __init__(self, db):
-        """See zope.app.process.interfaces.IPublicationRequestFactory"""
+        """See zope.app.publication.interfaces.IPublicationRequestFactory"""
         self._http = HTTPPublication(db)
         self._brower = BrowserPublication(db)
         self._xmlrpc = XMLRPCPublication(db)
 
     def __call__(self, input_stream, output_steam, env):
-        """See zope.app.process.interfaces.IPublicationRequestFactory"""
+        """See zope.app.publication.interfaces.IPublicationRequestFactory"""
         method = env.get('REQUEST_METHOD', 'GET').upper()
 
         if method in _browser_methods:

Added: Zope3/trunk/src/zope/app/publication/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/interfaces.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/publication/interfaces.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# 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.interface import Interface
+
+
+class IPublicationRequestFactoryFactory(Interface):
+    """Publication request factory factory"""
+
+    def realize(db):
+        """Create a publication and request factory for a given database
+
+        Return a IPublicationRequestFactory for the given database.
+        """
+
+
+class IPublicationRequestFactory(Interface):
+    """Publication request factory"""
+
+    def __call__(input_stream, output_steam, env):
+        """Create a request object to handle the given inputs
+
+        A request is created and configured with a publication object.
+        """
+
+
+class IRequestFactory(IPublicationRequestFactory,
+                      IPublicationRequestFactoryFactory):
+    """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.
+    """


Property changes on: Zope3/trunk/src/zope/app/publication/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/server/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/server/__init__.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/server/__init__.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1 +1 @@
-# import this
+# Make this a package.

Modified: Zope3/trunk/src/zope/app/server/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/server/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/server/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,8 +1,70 @@
-<configure 
-    xmlns="http://namespaces.zope.org/zope">
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:startup="http://namespaces.zope.org/startup"
+   xmlns:event="http://namespaces.zope.org/event"
+   >
 
   <utility 
       component=".servercontrol.serverControl"
       provides="zope.app.applicationcontrol.interfaces.IServerControl" />
 
+  <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"/>
+
+  <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" />
+
+  <startup:registerServerType 
+      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" />
+
+  <startup:registerServerType 
+      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" />
+
 </configure>

Copied: Zope3/trunk/src/zope/app/server/interfaces.py (from rev 24841, Zope3/trunk/src/zope/app/process/interfaces.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/interfaces.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/interfaces.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Interfaces for the zope.app.server package.
+
+$Id$
+"""
+
+from zope.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."""

Copied: Zope3/trunk/src/zope/app/server/main.py (from rev 24841, Zope3/trunk/src/zope/app/process/main.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/main.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/main.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,100 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Functions that control how the Zope appserver knits itself together.
+
+$Id$
+"""
+
+import logging
+import os
+import sys
+import time
+
+from zdaemon import zdoptions
+
+import ThreadedAsync
+
+import zope.app.appsetup
+from zope.app.event import publish
+from zope.server.taskthreads import ThreadedTaskDispatcher
+
+CONFIG_FILENAME = "zope.conf"
+
+
+class ZopeOptions(zdoptions.ZDOptions):
+
+    logsectionname = None
+
+    def default_configfile(self):
+        dir = os.path.normpath(
+            os.path.join(os.path.dirname(__file__),
+                         os.pardir, os.pardir, os.pardir, os.pardir))
+        for filename in [CONFIG_FILENAME, CONFIG_FILENAME + ".in"]:
+            filename = os.path.join(dir, filename)
+            if os.path.isfile(filename):
+                return filename
+        return None
+
+
+def main(args=None):
+    # Record start times (real time and CPU time)
+    t0 = time.time()
+    c0 = time.clock()
+
+    setup(args)
+
+    t1 = time.time()
+    c1 = time.clock()
+    logging.info("Startup time: %.3f sec real, %.3f sec CPU", t1-t0, c1-c0)
+
+    run()
+    sys.exit(0)
+
+
+def run():
+    try:
+        ThreadedAsync.loop()
+    except KeyboardInterrupt:
+        # Exit without spewing an exception.
+        pass
+
+
+def setup(args=None):
+    if args is None:
+        args = sys.argv[1:]
+    options = ZopeOptions()
+    options.schemadir = os.path.dirname(os.path.abspath(__file__))
+    options.realize(args)
+    options = options.configroot
+
+    if options.path:
+        sys.path[:0] = [os.path.abspath(p) for p in options.path]
+
+    sys.setcheckinterval(options.check_interval)
+
+    options.eventlog()
+
+    zope.app.appsetup.config(options.site_definition)
+
+    db = options.database.open()
+
+    publish(None, zope.app.appsetup.DatabaseOpened(db))
+
+    task_dispatcher = ThreadedTaskDispatcher()
+    task_dispatcher.setThreadCount(options.threads)
+
+    for server in options.servers:
+        server.create(task_dispatcher, db)
+
+    publish(None, zope.app.appsetup.ProcessStarting())

Copied: Zope3/trunk/src/zope/app/server/meta.zcml (from rev 24841, Zope3/trunk/src/zope/app/process/meta.zcml)

Copied: Zope3/trunk/src/zope/app/server/metaconfigure.py (from rev 24841, Zope3/trunk/src/zope/app/process/metaconfigure.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/metaconfigure.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/metaconfigure.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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' ZCML namespace directives.
+
+$Id$
+"""
+from zope.app.server import requestfactoryregistry
+from zope.app.server import servertyperegistry
+from zope.app.server.requestfactory import RequestFactory
+from zope.app.server.servertype import ServerType
+
+
+def registerRequestFactory(_context, name, request=None, publication=None,
+                           factory=None):
+
+    if factory:
+        if request or publication:
+            raise ValuesError(
+                """You cannot provide a request or publication (factory) if you
+                provide a (request) factory""")
+        request_factory = factory
+
+    else:
+        request_factory = RequestFactory(publication, request)
+
+    _context.action(
+            discriminator = name,
+            callable = requestfactoryregistry.registerRequestFactory,
+            args = (name, request_factory,) )
+
+
+def registerServerType(_context, name, factory, requestFactory, logFactory,
+                       defaultPort, defaultVerbose):
+
+    server_type = ServerType(name, factory, requestFactory, logFactory,
+                             defaultPort, defaultVerbose)
+
+    _context.action(
+            discriminator = name,
+            callable = servertyperegistry.registerServerType,
+            args = (name, server_type) )

Copied: Zope3/trunk/src/zope/app/server/metadirectives.py (from rev 24841, Zope3/trunk/src/zope/app/process/metadirectives.py)

Copied: Zope3/trunk/src/zope/app/server/mkzopeinstance.py (from rev 24841, Zope3/trunk/src/zope/app/process/mkzopeinstance.py)

Copied: Zope3/trunk/src/zope/app/server/refactor.txt (from rev 24841, Zope3/trunk/src/zope/app/process/refactor.txt)

Copied: Zope3/trunk/src/zope/app/server/requestfactory.py (from rev 24841, Zope3/trunk/src/zope/app/process/requestfactory.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/requestfactory.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/requestfactory.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Request Factory
+
+$Id$
+"""
+import copy
+from zope.app.publication.interfaces import IRequestFactory
+from zope.interface import implements
+
+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
+
+
+    def realize(self, db):
+        'See IRequestFactory'
+        realized = copy.copy(self)
+        realized._publication = realized._pubFactory(db)
+        return realized
+
+
+    def __call__(self, input_stream, output_steam, env):
+        'See IRequestFactory'
+        request = self._request(input_stream, output_steam, env)
+        request.setPublication(self._publication)
+        return request

Copied: Zope3/trunk/src/zope/app/server/requestfactoryregistry.py (from rev 24841, Zope3/trunk/src/zope/app/process/requestfactoryregistry.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/requestfactoryregistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/requestfactoryregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# 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.interface import implements
+from zope.app.server.interfaces import ISimpleRegistry
+from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
+from zope.app.server.simpleregistry import SimpleRegistry
+
+
+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.
+    """
+
+
+class RequestFactoryRegistry(SimpleRegistry):
+    implements(IRequestFactoryRegistry)
+
+
+RequestFactoryRegistry = RequestFactoryRegistry(
+    IPublicationRequestFactoryFactory)
+
+registerRequestFactory = RequestFactoryRegistry.register
+getRequestFactory = RequestFactoryRegistry.get
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from zope.testing.cleanup import addCleanUp
+addCleanUp(RequestFactoryRegistry._clear)
+del addCleanUp

Copied: Zope3/trunk/src/zope/app/server/schema.xml (from rev 24841, Zope3/trunk/src/zope/app/process/schema.xml)
===================================================================
--- Zope3/trunk/src/zope/app/process/schema.xml	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/schema.xml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,81 @@
+<schema>
+  <description>
+    Zope 3 configuration schema.
+
+    This schema describes the configuration options available to a
+    site administrator via the zope.conf configuration file.
+  </description>
+
+  <!-- database and storage types -->
+  <import package="ZODB" />
+
+  <!-- logging configuration -->
+  <import package="ZConfig.components.logger" />
+
+  <sectiontype name="server" datatype="zope.app.server.server.ServerFactory">
+    <key name="type" required="yes" />
+    <key name="address" datatype="inet-address" />
+    <key name="verbose" datatype="boolean" />
+  </sectiontype>
+
+  <section type="ZODB.database" name="*" required="yes"
+           attribute="database">
+    <description>
+      The main application database that should be used.
+    </description>
+  </section>
+
+  <section type="eventlog" attribute="eventlog" name="*">
+    <description>
+      Configuration for the event log.
+    </description>
+  </section>
+
+  <multisection type="server" name="*" attribute="servers" />
+
+  <key name="site-definition" default="site.zcml">
+    <description>
+      The name of the top-level ZCML file that defines the component
+      configuration used for this site.
+    </description>
+  </key>
+
+  <key name="interrupt-check-interval" datatype="integer" default="120"
+       attribute="check_interval">
+    <description>
+      Value passed to Python's sys.setcheckinterval() function.
+
+      This integer value determines how often the interpreter checks
+      for periodic things such as thread switches and signal handlers.
+      Setting it to a larger value may increase performance for
+      programs using threads.  Setting it to a value &lt;= 0 checks every
+      virtual instruction, maximizing responsiveness as well as
+      overhead.
+    </description>
+  </key>
+
+  <key name="threads" datatype="integer" default="4">
+    <description>
+      The number of threads which should be used to serve requests.
+
+      The threads are placed in a pool and are used to serve requests
+      received from the servers configured using &lt;server&gt;
+      sections.  This does not constrain the total number of threads
+      used by the application server; additional threads may be used
+      for internal purposes.
+    </description>
+  </key>
+
+  <multikey name="path" datatype="string">
+    <description>
+      This specifies additional paths directories which are inserted into
+      the beginning of Python's module search path.  The set of directories
+      specified is inserted into the beginning of the module search path in
+      the order which they are specified here.  Note that the processing of
+      this directive may happen too late under some circumstances; it is
+      recommended that you use the PYTHONPATH environment variable if
+      using this directive doesn't work for you.
+    </description>
+    <metadefault>$softwarehome/src</metadefault>
+  </multikey>
+</schema>

Copied: Zope3/trunk/src/zope/app/server/server.py (from rev 24841, Zope3/trunk/src/zope/app/process/server.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/server.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/server.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+
+"""Datatype for a <server> section in a Zope 3 configuration file.
+
+This is called by the ZConfig machinery while processing a configuration.
+
+$Id$
+"""
+
+from zope.app.server.servertyperegistry import getServerType
+
+
+class ServerFactory:
+    """Factory for server objects.
+
+    The factories are part of the configuration data returned by
+    ZConfig.
+    """
+
+    def __init__(self, section):
+        """Initialize the factory based on a <server> section."""
+        self.type = section.type
+        self.address = section.address
+        self.verbose = section.verbose
+
+    def create(self, task_dispatcher, database):
+        """Return a server based on the server types defined via ZCML."""
+        servertype = getServerType(self.type)
+        # The server object self-registers with the asyncore mainloop.
+        servertype.create(task_dispatcher, database,
+                          self.address[1], # XXX maybe improve API
+                          self.verbose)

Copied: Zope3/trunk/src/zope/app/server/servertype.py (from rev 24841, Zope3/trunk/src/zope/app/process/servertype.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/servertype.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/servertype.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# 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 zope.interface import Interface, implements
+from zope.app.server.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
+
+
+    def create(self, task_dispatcher, db, port=None, verbose=None):
+        'See 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()})

Copied: Zope3/trunk/src/zope/app/server/servertyperegistry.py (from rev 24841, Zope3/trunk/src/zope/app/process/servertyperegistry.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/servertyperegistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/servertyperegistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# 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.server.interfaces import ISimpleRegistry
+from zope.app.server.servertype import IServerType
+from zope.app.server.simpleregistry import SimpleRegistry
+from zope.interface import implements
+
+
+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.
+    """
+
+
+class ServerTypeRegistry(SimpleRegistry):
+    """Registry for the various Server types"""
+    implements(IServerTypeRegistry)
+
+
+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

Copied: Zope3/trunk/src/zope/app/server/simpleregistry.py (from rev 24841, Zope3/trunk/src/zope/app/process/simpleregistry.py)
===================================================================
--- Zope3/trunk/src/zope/app/process/simpleregistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/simpleregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -0,0 +1,86 @@
+##############################################################################
+#
+# 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.server.interfaces import ISimpleRegistry
+from zope.interface import implements
+
+ListTypes = (tuple, list)
+
+
+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.getName() + ".")
+
+
+class SimpleRegistry:
+    """ """
+
+    implements(ISimpleRegistry)
+
+    def __init__(self, interface):
+        """Initialize registry"""
+        self.objects = {}
+        self.interface = interface
+
+    def _clear(self):
+        self.objects.clear()
+
+    def register(self, name, object):
+        '''See ISimpleRegistry'''
+
+        if name in self.objects.keys():
+            raise ZopeDuplicateRegistryEntryError(name)
+
+        if self.interface.providedBy(object):
+            self.objects[name] = object
+        else:
+            raise ZopeIllegalInterfaceError(name, self.interface)
+
+        return []
+
+    def get(self, name):
+        '''See ISimpleRegistry'''
+        if name in self.objects.keys():
+            return self.objects[name]
+        else:
+            return None

Copied: Zope3/trunk/src/zope/app/server/tests (from rev 24841, Zope3/trunk/src/zope/app/process/tests)

Modified: Zope3/trunk/src/zope/app/server/tests/startup.zcml
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/startup.zcml	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/startup.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,7 +1,7 @@
 <configure xmlns="http://namespaces.zope.org/zope"
            xmlns:startup="http://namespaces.zope.org/startup">
 
-  <include package="zope.app.process" file="meta.zcml"/>
+  <include package="zope.app.server" file="meta.zcml"/>
 
   <startup:registerServerType
       name="Browser"
@@ -18,6 +18,6 @@
 
   <startup:registerRequestFactory
       name="BrowserRequestFactory2"
-      factory="zope.app.process.tests.test_directives.tf"/>
+      factory="zope.app.server.tests.test_directives.tf"/>
  
 </configure>

Deleted: Zope3/trunk/src/zope/app/server/tests/test_bootstrap.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_bootstrap.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_bootstrap.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -1,192 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Bootstrap tests
-
-$Id$
-"""
-import unittest
-from transaction import get_transaction
-from ZODB.tests.util import DB
-from zope.exceptions import NotFoundError
-
-from zope.app.folder import rootFolder
-from zope.app.folder.interfaces import IRootFolder
-from zope.app.errorservice.interfaces import IErrorReportingService
-from zope.app.principalannotation.interfaces import IPrincipalAnnotationService
-from zope.app.event.interfaces import IEventService
-from zope.app.hub.interfaces import IObjectHub
-from zope.app.publication.zopepublication import ZopePublication
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.errorservice import ErrorReportingService
-from zope.app.servicenames import ErrorLogging
-from zope.app.traversing import traverse
-from zope.app.site.service import ServiceManager
-
-class EventStub(object):
-
-    def __init__(self, db):
-        self.database = db
-
-
-class TestBootstrapSubscriberBase(PlacefulSetup, unittest.TestCase):
-
-    def setUp(self):
-        PlacefulSetup.setUp(self)
-        self.db = DB()
-
-    def tearDown(self):
-        PlacefulSetup.tearDown(self)
-        self.db.close()
-
-    def createRootFolder(self):
-        cx = self.db.open()
-        root = cx.root()
-        self.root_folder = rootFolder()
-        root[ZopePublication.root_name] = self.root_folder
-        get_transaction().commit()
-        cx.close()
-
-    def createRFAndSM(self):
-        cx = self.db.open()
-        root = cx.root()
-        self.root_folder = rootFolder()
-        root[ZopePublication.root_name] = self.root_folder
-        self.service_manager = ServiceManager(self.root_folder)
-        self.root_folder.setSiteManager(self.service_manager)
-        get_transaction().commit()
-        cx.close()
-
-
-    def test_notify(self):
-        from zope.app.process.bootstrap import BootstrapSubscriberBase
-
-        for setup in (lambda: None), self.createRootFolder, self.createRFAndSM:
-
-            setup()
-
-            BootstrapSubscriberBase().notify(EventStub(self.db))
-
-            cx = self.db.open()
-            root = cx.root()
-            root_folder = root.get(ZopePublication.root_name, None)
-            self.assert_(IRootFolder.providedBy(root_folder))
-
-            package_name = '/++etc++site/default'
-            package = traverse(root_folder, package_name)
-
-            cx.close()
-
-    def test_ensureService(self):
-        from zope.app.process.bootstrap import BootstrapSubscriberBase
-
-        self.createRFAndSM()
-        bs = BootstrapSubscriberBase()
-        bs.notify(EventStub(self.db))
-        for i in range(2):
-            cx = self.db.open()
-            name = bs.ensureService(ErrorLogging, ErrorReportingService)
-
-            if i == 0:
-                self.assertEqual(name, 'ErrorLogging')
-            else:
-                self.assertEqual(name, None)
-
-            root = cx.root()
-            root_folder = root[ZopePublication.root_name]
-
-            package_name = '/++etc++site/default'
-            package = traverse(root_folder, package_name)
-
-            self.assert_(IErrorReportingService.providedBy(
-                traverse(package, 'ErrorLogging')))
-            get_transaction().commit()
-            cx.close()
-
-class TestBootstrapInstance(TestBootstrapSubscriberBase):
-
-    def test_bootstrapInstance(self):
-        from zope.app.process.bootstrap import bootstrapInstance
-
-        bootstrapInstance.notify(EventStub(self.db))
-
-        cx = self.db.open()
-        root = cx.root()
-        root_folder = root[ZopePublication.root_name]
-
-        package_name = '/++etc++site/default'
-        package = traverse(root_folder, package_name)
-
-        self.assert_(IEventService.providedBy(
-            traverse(package, 'EventPublication')))
-
-        self.assert_(IObjectHub.providedBy(
-            traverse(package, 'HubIds')))
-
-        self.assert_(IErrorReportingService.providedBy(
-            traverse(package, 'ErrorLogging')))
-
-        self.assert_(IPrincipalAnnotationService.providedBy(
-            traverse(package, 'PrincipalAnnotation')))
-
-        cx.close()
-
-    def test_bootstrapInstance_withServices(self):
-        from zope.app.process.bootstrap import bootstrapInstance
-        from zope.app.process.bootstrap import addService, configureService
-
-        self.createRFAndSM()
-
-        name = addService(self.root_folder, 'Errors',
-                          ErrorReportingService, copy_to_zlog=True)
-        configureService(self.root_folder, ErrorLogging, name)
-
-        bootstrapInstance.notify(EventStub(self.db))
-
-        cx = self.db.open()
-        root = cx.root()
-        root_folder = root[ZopePublication.root_name]
-
-        package_name = '/++etc++site/default'
-        package = traverse(root_folder, package_name)
-
-        self.assert_(IEventService.providedBy(
-            traverse(package, 'EventPublication')))
-
-        self.assert_(IObjectHub.providedBy(
-            traverse(package, 'HubIds')))
-
-        self.assertRaises(NotFoundError, traverse, root_folder,
-                          '/++etc++site/default/ErrorLogging')
-
-        self.assert_(IErrorReportingService.providedBy(
-            traverse(package, 'Errors')))
-
-        self.assert_(IEventService.providedBy(
-            traverse(package, 'EventPublication')))
-
-        self.assert_(IPrincipalAnnotationService.providedBy(
-            traverse(package, 'PrincipalAnnotation')))
-
-        cx.close()
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(TestBootstrapSubscriberBase))
-    suite.addTest(unittest.makeSuite(TestBootstrapInstance))
-    return suite
-
-
-if __name__ == '__main__':
-    unittest.main()

Modified: Zope3/trunk/src/zope/app/server/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_directives.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_directives.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -16,9 +16,9 @@
 $Id$
 """
 import unittest
-from zope.app.process.interfaces import IPublicationRequestFactoryFactory
-from zope.app.process.requestfactoryregistry import getRequestFactory
-from zope.app.process.servertyperegistry import getServerType
+from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
+from zope.app.server.requestfactoryregistry import getRequestFactory
+from zope.app.server.servertyperegistry import getServerType
 from zope.app.publication.browser import BrowserPublication
 from zope.configuration import xmlconfig
 from zope.interface import implements
@@ -26,7 +26,7 @@
 from zope.server.http.publisherhttpserver import PublisherHTTPServer
 from zope.server.http.commonhitlogger import CommonHitLogger
 from zope.testing.cleanup import CleanUp
-import zope.app.process.tests
+import zope.app.server.tests
 
 class TF:
     "test request factory"
@@ -39,7 +39,7 @@
 
     def setUp(self):
         CleanUp.setUp(self)
-        self.context = xmlconfig.file("startup.zcml", zope.app.process.tests)
+        self.context = xmlconfig.file("startup.zcml", zope.app.server.tests)
 
     def test_registerServerType(self):
         self.assertEqual(getServerType('Browser')._factory,

Modified: Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_mkzopeinstance.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -23,7 +23,7 @@
 
 from StringIO import StringIO
 
-from zope.app.process import mkzopeinstance
+from zope.app.server import mkzopeinstance
 
 
 class TestBase(unittest.TestCase):

Modified: Zope3/trunk/src/zope/app/server/tests/test_requestfactoryregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_requestfactoryregistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_requestfactoryregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -19,9 +19,9 @@
 """
 
 import unittest
-from zope.app.process.requestfactoryregistry import \
+from zope.app.server.requestfactoryregistry import \
      registerRequestFactory, getRequestFactory
-from zope.app.process.requestfactory import IRequestFactory
+from zope.app.publication.interfaces import IRequestFactory
 from zope.interface import implements
 
 

Modified: Zope3/trunk/src/zope/app/server/tests/test_servertyperegistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_servertyperegistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_servertyperegistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -19,9 +19,9 @@
 """
 
 import unittest
-from zope.app.process.servertyperegistry import \
+from zope.app.server.servertyperegistry import \
      registerServerType, getServerType
-from zope.app.process.servertype import IServerType
+from zope.app.server.servertype import IServerType
 from zope.interface import implements
 
 

Modified: Zope3/trunk/src/zope/app/server/tests/test_simpleregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/process/tests/test_simpleregistry.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/server/tests/test_simpleregistry.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -18,7 +18,7 @@
 
 import unittest
 from zope.interface import Interface
-from zope.app.process.simpleregistry import SimpleRegistry, \
+from zope.app.server.simpleregistry import SimpleRegistry, \
      ZopeDuplicateRegistryEntryError, ZopeIllegalInterfaceError
 from zope.interface import implements
 

Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/tests/functional.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -33,7 +33,7 @@
 from zope.exceptions import Forbidden, Unauthorized
 from zope.security.management import endInteraction
 
-from zope.app import Application
+from zope.app.debug import Debugger
 from zope.app.publication.zopepublication import ZopePublication
 from zope.app.publication.http import HTTPPublication
 import zope.app.tests.setup
@@ -99,7 +99,7 @@
             logging.root.addHandler(logging.StreamHandler(self.log))
             self.base_storage = DemoStorage("Memory Storage")
             self.db = DB(self.base_storage)
-            self.app = Application(self.db, config_file)
+            self.app = Debugger(self.db, config_file)
             self.connection = None
             self._config_file = config_file
             self._init = True

Modified: Zope3/trunk/src/zope/app/undo/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/undo/configure.zcml	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/src/zope/app/undo/configure.zcml	2004-05-20 21:14:51 UTC (rev 24843)
@@ -22,7 +22,7 @@
 
   <event:subscribe
       subscriber=".undoSetup"
-      event_types="zope.app.event.interfaces.IDatabaseOpenedEvent"
+      event_types="zope.app.appsetup.IDatabaseOpenedEvent"
       />
 
 

Modified: Zope3/trunk/z3.py
===================================================================
--- Zope3/trunk/z3.py	2004-05-20 21:13:29 UTC (rev 24842)
+++ Zope3/trunk/z3.py	2004-05-20 21:14:51 UTC (rev 24843)
@@ -55,7 +55,7 @@
     srcdir = os.path.abspath(src)
     sys.path = [srcdir, here] + basepath
 
-    from zope.app.process.main import main
+    from zope.app.server.main import main
     main(argv[1:])
 
 




More information about the Zope3-Checkins mailing list