[Zope-Checkins] SVN: Zope/trunk/ Moved the code handling ZCML loading into the ``Zope2.App`` package. The component architecture is now setup before the application object is created or any database connections are opened. So far the CA was setup somewhat randomly in the startup process, when the ``Five`` product was initialized.

Hanno Schlichting hannosch at hannosch.eu
Tue Mar 30 17:14:24 EDT 2010


Log message for revision 110339:
  Moved the code handling ZCML loading into the ``Zope2.App`` package. The component architecture is now setup before the application object is created or any database connections are opened. So far the CA was setup somewhat randomly in the startup process, when the ``Five`` product was initialized.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/OFS/tests/testCopySupportEvents.py
  U   Zope/trunk/src/OFS/tests/testCopySupportHooks.py
  U   Zope/trunk/src/OFS/tests/testObjectManager.py
  U   Zope/trunk/src/OFS/tests/testTraverse.py
  U   Zope/trunk/src/OFS/tests/test_registerclass.py
  U   Zope/trunk/src/OFS/tests/test_registerpackage.py
  U   Zope/trunk/src/Products/Five/__init__.py
  U   Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/provider.txt
  U   Zope/trunk/src/Products/Five/browser/tests/resource.txt
  U   Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt
  U   Zope/trunk/src/Products/Five/browser/tests/skin.txt
  U   Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_i18n.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_menu.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_pages.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_traversable.py
  U   Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py
  U   Zope/trunk/src/Products/Five/component/makesite.txt
  U   Zope/trunk/src/Products/Five/schema.py
  U   Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py
  U   Zope/trunk/src/Products/Five/tests/boilerplate.py
  U   Zope/trunk/src/Products/Five/tests/test_directives.py
  U   Zope/trunk/src/Products/Five/tests/test_i18n.py
  U   Zope/trunk/src/Products/Five/tests/test_size.py
  U   Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py
  U   Zope/trunk/src/Products/Five/viewlet/README.txt
  U   Zope/trunk/src/Products/Five/viewlet/directives.txt
  U   Zope/trunk/src/Products/Five/zcml.py
  U   Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
  U   Zope/trunk/src/Testing/ZopeTestCase/placeless.py
  U   Zope/trunk/src/Testing/ZopeTestCase/zopedoctest/testPackageAsProduct.py
  A   Zope/trunk/src/Zope2/App/schema.py
  U   Zope/trunk/src/Zope2/App/startup.py
  A   Zope/trunk/src/Zope2/App/zcml.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/doc/CHANGES.rst	2010-03-30 21:14:23 UTC (rev 110339)
@@ -11,6 +11,11 @@
 Restructuring
 +++++++++++++
 
+- Moved the code handling ZCML loading into the ``Zope2.App`` package. The
+  component architecture is now setup before the application object is created
+  or any database connections are opened. So far the CA was setup somewhat
+  randomly in the startup process, when the ``Five`` product was initialized.
+
 - Downgrade the ``manage_* is discouraged. You should use event subscribers
   instead`` warnings to debug level logging. This particular warning hasn't
   motivated anyone to actually change any code.

Modified: Zope/trunk/src/OFS/tests/testCopySupportEvents.py
===================================================================
--- Zope/trunk/src/OFS/tests/testCopySupportEvents.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/testCopySupportEvents.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -13,12 +13,13 @@
 from OFS.SimpleItem import SimpleItem
 from OFS.Folder import Folder
 
+from Zope2.App import zcml
+
 from zope import interface
 from zope import component
 from zope.component.interfaces import IObjectEvent
 
 from zope.testing import cleanup
-from Products.Five import zcml
 
 
 class EventLogger(object):
@@ -59,15 +60,13 @@
     @classmethod
     def setUp(cls):
         cleanup.cleanUp()
-        zcml._initialized = 0
-        zcml.load_site()
+        zcml.load_site(force=True)
         component.provideHandler(eventlog.trace, (ITestItem, IObjectEvent))
         component.provideHandler(eventlog.trace, (ITestFolder, IObjectEvent))
 
     @classmethod
     def tearDown(cls):
         cleanup.cleanUp()
-        zcml._initialized = 0
 
 
 class EventTest(unittest.TestCase):

Modified: Zope/trunk/src/OFS/tests/testCopySupportHooks.py
===================================================================
--- Zope/trunk/src/OFS/tests/testCopySupportHooks.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/testCopySupportHooks.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -6,7 +6,6 @@
 import transaction
 
 from zope.testing import cleanup
-from Products.Five import zcml
 
 from Testing.makerequest import makerequest
 
@@ -16,7 +15,9 @@
 from OFS.SimpleItem import SimpleItem
 from OFS.Folder import Folder
 
+from Zope2.App import zcml
 
+
 class EventLogger(object):
     def __init__(self):
         self.reset()
@@ -64,15 +65,13 @@
     @classmethod
     def setUp(cls):
         cleanup.cleanUp()
-        zcml._initialized = 0
-        zcml.load_site()
+        zcml.load_site(force=True)
         setDeprecatedManageAddDelete(TestItem)
         setDeprecatedManageAddDelete(TestFolder)
 
     @classmethod
     def tearDown(cls):
         cleanup.cleanUp()
-        zcml._initialized = 0
 
 
 class HookTest(unittest.TestCase):

Modified: Zope/trunk/src/OFS/tests/testObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/tests/testObjectManager.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/testObjectManager.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -15,7 +15,7 @@
 from OFS.ObjectManager import ObjectManager
 from OFS.SimpleItem import SimpleItem
 import Products.Five
-from Products.Five import zcml
+from Zope2.App import zcml
 from zExceptions import BadRequest
 
 logger = getLogger('OFS.subscribers')            

Modified: Zope/trunk/src/OFS/tests/testTraverse.py
===================================================================
--- Zope/trunk/src/OFS/tests/testTraverse.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/testTraverse.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -414,7 +414,7 @@
     publishing they do unrestrictedTraverse.
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> from Testing.makerequest import makerequest
       >>> self.app = makerequest(self.app)
@@ -594,7 +594,7 @@
       ...       />
       ... </configure>'''
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> zcml.load_string(configure_zcml)
 

Modified: Zope/trunk/src/OFS/tests/test_registerclass.py
===================================================================
--- Zope/trunk/src/OFS/tests/test_registerclass.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/test_registerclass.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -24,7 +24,7 @@
       >>> setUp()
       >>> import Products
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> from Products.Five.tests.testing.simplecontent import SimpleContent
       >>> from Products.Five.tests.testing.simplecontent import ISimpleContent
       >>> from persistent.interfaces import IPersistent

Modified: Zope/trunk/src/OFS/tests/test_registerpackage.py
===================================================================
--- Zope/trunk/src/OFS/tests/test_registerpackage.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/OFS/tests/test_registerpackage.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -30,7 +30,7 @@
       >>> setUp()
       >>> import Products
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', Products.Five)
 
     Make sure a python package with a valid initialize gets its

Modified: Zope/trunk/src/Products/Five/__init__.py
===================================================================
--- Zope/trunk/src/Products/Five/__init__.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/__init__.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -15,22 +15,12 @@
 
 $Id$
 """
-from Products.Five import zcml
 
 # public API provided by Five
 # usage: from Products.Five import <something>
 from Products.Five.browser import BrowserView
 from Products.Five.skin.standardmacros import StandardMacros
 
-# load the site's ZCML tree (usually site.zcml) upon product
-# initialization
-def initialize(context):
-    from zope.schema.vocabulary import setVocabularyRegistry
-    from Products.Five.schema import Zope2VocabularyRegistry
-
-    zcml.load_site()
-    setVocabularyRegistry(Zope2VocabularyRegistry())
-
 # some convenience methods/decorators
 
 def fivemethod(func):

Modified: Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/aqlegacy_ftest.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -5,7 +5,7 @@
 some:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('aqlegacy.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/pages.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/pages.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -4,7 +4,7 @@
 Let's register a quite large amount of test pages:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -5,7 +5,7 @@
 some:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/provider.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/provider.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/provider.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -9,7 +9,7 @@
 
   >>> from zope.contentprovider import interfaces
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('provider.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/resource.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/resource.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/resource.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -4,7 +4,7 @@
 Set up the test fixtures:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('resource.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/resource_ftest.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -4,7 +4,7 @@
 Set up the test fixtures:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config('resource.zcml', package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/skin.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/skin.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/skin.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -4,7 +4,7 @@
 Let's register a test layer and test skin:
 
   >>> import Products.Five.browser.tests
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
   >>> zcml.load_config("skin.zcml", package=Products.Five.browser.tests)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_absoluteurl.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -23,7 +23,7 @@
     First we make some preparations:
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
 
       >>> from Products.Five.tests.testing import manage_addFiveTraversableFolder

Modified: Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_defaultview.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -24,7 +24,7 @@
     default viewable:
 
       >>> import Products.Five.browser.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> zcml.load_config('defaultview.zcml', Products.Five.browser.tests)
 
@@ -114,7 +114,7 @@
 
       >>> import AccessControl
       >>> import Products.Five.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', Products.Five)
       >>> zcml.load_config("permissions.zcml", AccessControl)
       >>> zcml.load_config('directives.zcml', Products.Five.tests)

Modified: Zope/trunk/src/Products/Five/browser/tests/test_i18n.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_i18n.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_i18n.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -40,7 +40,7 @@
       ... </configure>'''
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> zcml.load_string(configure_zcml)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_menu.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_menu.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_menu.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -25,7 +25,7 @@
 
       >>> import AccessControl
       >>> import Products.Five.browser.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("meta.zcml", Products.Five)
       >>> zcml.load_config("permissions.zcml", AccessControl)
       >>> zcml.load_config('menu.zcml', package=Products.Five.browser.tests)

Modified: Zope/trunk/src/Products/Five/browser/tests/test_pages.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_pages.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_pages.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -23,7 +23,7 @@
     provide dummy contexts which are not wrapped.
 
     >>> import Products.Five.browser.tests
-    >>> from Products.Five import zcml
+    >>> from Zope2.App import zcml
     >>> zcml.load_config("configure.zcml", Products.Five)
     >>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
     >>> from Products.Five.tests.testing import simplecontent as sc

Modified: Zope/trunk/src/Products/Five/browser/tests/test_traversable.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_traversable.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_traversable.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -25,7 +25,7 @@
     Test the behaviour of Five-traversable classes.
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
 
     ``SimpleContent`` is a traversable class by default.  Its fallback
@@ -211,7 +211,7 @@
       ...       />
       ... </configure>'''
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> zcml.load_string(configure_zcml)
 

Modified: Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/browser/tests/test_zope3security.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -23,7 +23,7 @@
       ... </configure>'''
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config("configure.zcml", Products.Five)
       >>> zcml.load_string(configure_zcml)
 

Modified: Zope/trunk/src/Products/Five/component/makesite.txt
===================================================================
--- Zope/trunk/src/Products/Five/component/makesite.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/component/makesite.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -13,7 +13,7 @@
 Load all of Five's configuration (this is a functional test):
 
     >>> import Products.Five
-    >>> from Products.Five.zcml import load_config
+    >>> from Zope2.App.zcml import load_config
     >>> load_config('configure.zcml', package=Products.Five)
 
 Enable local component lookup hooks:

Modified: Zope/trunk/src/Products/Five/schema.py
===================================================================
--- Zope/trunk/src/Products/Five/schema.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/schema.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -1,36 +1,3 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Five-specific schema support
+# BBB
 
-$Id$
-"""
-from zope.component import getUtility
-from zope.interface import implements
-from zope.schema.interfaces import IVocabularyRegistry
-from zope.schema.interfaces import IVocabularyFactory
-
-class Zope2VocabularyRegistry(object):
-    """IVocabularyRegistry that supports global and local utilities.
-
-    Cloned from the version in zope.app.schema.vocabulary:  it was the
-    only feature in that package!
-    """
-    implements(IVocabularyRegistry)
-    __slots__ = ()
-
-    def get(self, context, name):
-        """See zope.schema.interfaces.IVocabularyRegistry.
-        """
-        factory = getUtility(IVocabularyFactory, name)
-        return factory(context)
+from Zope2.App.schema import Zope2VocabularyRegistry

Modified: Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py
===================================================================
--- Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/skin/tests/test_standardmacros.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -27,7 +27,7 @@
       >>> manage_addFiveTraversableFolder(self.folder, 'testoid', 'Testoid')
 
       >>> import Products.Five.skin.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('configure.zcml', package=Products.Five)
       >>> zcml.load_config('configure.zcml', package=Products.Five.skin.tests)    
 

Modified: Zope/trunk/src/Products/Five/tests/boilerplate.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/boilerplate.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/tests/boilerplate.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -22,7 +22,7 @@
       >>> setUp()
 
       >>> import Products.Five.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('boilerplate.zcml', Products.Five.tests)
 
       >>> from Products.Five.tests.testing import manage_addFiveTraversableFolder

Modified: Zope/trunk/src/Products/Five/tests/test_directives.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_directives.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/tests/test_directives.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -28,7 +28,7 @@
     But first, we load the configuration file:
 
       >>> import Products.Five.tests
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', Products.Five)
       >>> zcml.load_config('directives.zcml', Products.Five.tests)
 

Modified: Zope/trunk/src/Products/Five/tests/test_i18n.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_i18n.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/tests/test_i18n.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -24,7 +24,7 @@
     directive:
 
       >>> import zope.i18n
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', zope.i18n)
 
     Let's register the gettext locales using the ZCML directive:

Modified: Zope/trunk/src/Products/Five/tests/test_size.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/test_size.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/tests/test_size.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -72,7 +72,7 @@
       ... </configure>'''
 
       >>> import Products.Five
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', Products.Five)
       >>> zcml.load_string(configure_zcml)
 

Modified: Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py
===================================================================
--- Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/utilities/browser/tests/test_marker.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -25,7 +25,7 @@
       >>> import AccessControl
       >>> import Products.Five
       >>> import Products.Five.utilities
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
       >>> zcml.load_config('meta.zcml', Products.Five)
       >>> zcml.load_config('permissions.zcml', AccessControl)
       >>> zcml.load_config('configure.zcml', Products.Five.utilities)

Modified: Zope/trunk/src/Products/Five/viewlet/README.txt
===================================================================
--- Zope/trunk/src/Products/Five/viewlet/README.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/viewlet/README.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -12,7 +12,7 @@
 Setup traversal stuff
 
   >>> import Products.Five
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
 
 Set a loose security policy because these are unit tests, security will be

Modified: Zope/trunk/src/Products/Five/viewlet/directives.txt
===================================================================
--- Zope/trunk/src/Products/Five/viewlet/directives.txt	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/viewlet/directives.txt	2010-03-30 21:14:23 UTC (rev 110339)
@@ -5,7 +5,7 @@
 Setup traversal stuff
 
   >>> import Products.Five
-  >>> from Products.Five import zcml
+  >>> from Zope2.App import zcml
   >>> zcml.load_config("configure.zcml", Products.Five)
 
 The ``viewletManager`` directive allows you to quickly register a new viewlet
@@ -13,7 +13,6 @@
 directive. Before we can use the directives, we have to register their
 handlers by executing the package's meta configuration:
 
-  >>> from Products.Five import zcml
   >>> context = zcml.load_string('''
   ... <configure i18n_domain="zope">
   ...   <include package="Products.Five.viewlet" file="meta.zcml" />

Modified: Zope/trunk/src/Products/Five/zcml.py
===================================================================
--- Zope/trunk/src/Products/Five/zcml.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/Five/zcml.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -1,78 +1,9 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""ZCML machinery
+# BBB
 
-$Id$
-"""
-import os
-import os.path
-from zope.configuration import xmlconfig
+from Zope2.App.zcml import _context
+from Zope2.App.zcml import _initialized
 
-_initialized = False
-_context = None
-
-
-def load_site():
-    """Load a Five/Zope site by finding and loading the appropriate site
-    configuration file."""
-    global _initialized
-    if _initialized:
-        return
-    _initialized = True
-
-    import Globals
-    Globals.INSTANCE_HOME
-
-    # load instance site configuration file
-    site_zcml = os.path.join(Globals.INSTANCE_HOME, "etc", "site.zcml")
-
-    import Zope2.utilities
-    zope_utilities = os.path.dirname(Zope2.utilities.__file__)
-    skel_site_zcml = os.path.join(zope_utilities, "skel", "etc", "site.zcml")
-    
-    if os.path.exists(site_zcml):
-        file = site_zcml
-    else:
-        # check for zope installation home skel during running unit tests
-        file = skel_site_zcml
-
-    global _context
-    _context = xmlconfig.file(file)
-
-
-def load_config(file, package=None, execute=True):
-    """Load an additional ZCML file into the context.
-
-    Use with extreme care.
-    """
-    global _context
-    _context = xmlconfig.file(file, package, _context, execute=execute)
-
-def load_string(s):
-    """Load a snipped of ZCML into the context.
-
-    Use with extreme care.
-    """
-    global _context
-    _context = xmlconfig.string(s, _context)
-
-# clean up code
-
-def cleanUp():
-    global _context
-    _context = None
-
-from zope.testing.cleanup import addCleanUp
-addCleanUp(cleanUp)
-del addCleanUp
+from Zope2.App.zcml import load_site
+from Zope2.App.zcml import load_config
+from Zope2.App.zcml import load_string
+from Zope2.App.zcml import cleanUp

Modified: Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
===================================================================
--- Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -32,7 +32,7 @@
 from OFS.tests.testCopySupport import UnitTestSecurityPolicy
 from OFS.tests.testCopySupport import UnitTestUser
 
-from Products.Five import zcml
+from Zope2.App import zcml
 from Products.StandardCacheManagers.RAMCacheManager import RAMCacheManager
 from Products.StandardCacheManagers.AcceleratedHTTPCacheManager \
      import AcceleratedHTTPCacheManager

Modified: Zope/trunk/src/Testing/ZopeTestCase/placeless.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/placeless.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Testing/ZopeTestCase/placeless.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -52,7 +52,7 @@
 del ps
 
 # For convenience
-from Products.Five import zcml
+from Zope2.App import zcml
 
 
 def callZCML(zcml_callback):

Modified: Zope/trunk/src/Testing/ZopeTestCase/zopedoctest/testPackageAsProduct.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/zopedoctest/testPackageAsProduct.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Testing/ZopeTestCase/zopedoctest/testPackageAsProduct.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -15,11 +15,14 @@
 $Id$
 """
 
+import sys
 from unittest import TestSuite
+
+
 from Testing import ZopeTestCase
 from Testing.ZopeTestCase import ZopeLite
 from Testing.ZopeTestCase import ZopeDocTestSuite
-from Products.Five import zcml
+from Zope2.App import zcml
 from zope.testing import cleanup
 import Products
 
@@ -29,7 +32,7 @@
     Test if installPackage works.
 
       >>> from Testing import ZopeTestCase
-      >>> from Products.Five import zcml
+      >>> from Zope2.App import zcml
 
     Register testpackage
 
@@ -84,8 +87,7 @@
 
     def afterSetUp(self):
         cleanup.cleanUp()
-        zcml._initialized = False
-        zcml.load_site()
+        zcml.load_site(force=True)
 
         self.saved = sys.path[:]
         sys.path.append(ZopeTestCase.__path__[0])

Copied: Zope/trunk/src/Zope2/App/schema.py (from rev 110303, Zope/trunk/src/Products/Five/schema.py)
===================================================================
--- Zope/trunk/src/Zope2/App/schema.py	                        (rev 0)
+++ Zope/trunk/src/Zope2/App/schema.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+from zope.component import getUtility
+from zope.interface import implements
+from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import IVocabularyRegistry
+
+
+class Zope2VocabularyRegistry(object):
+    """IVocabularyRegistry that supports global and local utilities.
+    """
+
+    implements(IVocabularyRegistry)
+    __slots__ = ()
+
+    def get(self, context, name):
+        """See zope.schema.interfaces.IVocabularyRegistry.
+        """
+        factory = getUtility(IVocabularyFactory, name)
+        return factory(context)

Modified: Zope/trunk/src/Zope2/App/startup.py
===================================================================
--- Zope/trunk/src/Zope2/App/startup.py	2010-03-30 20:25:30 UTC (rev 110338)
+++ Zope/trunk/src/Zope2/App/startup.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -14,6 +14,10 @@
 """
 
 from zope.component import queryMultiAdapter
+from zope.event import notify
+from zope.processlifetime import DatabaseOpened
+from zope.schema.vocabulary import setVocabularyRegistry
+
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from Acquisition import aq_acquire
@@ -22,10 +26,8 @@
 from Acquisition import aq_parent
 from App.config import getConfiguration
 from time import asctime
-from types import StringType, ListType
 from zExceptions import upgradeException
 from zExceptions import Redirect
-from zExceptions import Unauthorized
 from ZODB.POSException import ConflictError
 import transaction
 import AccessControl.User
@@ -40,9 +42,6 @@
 import Zope2
 import ZPublisher
 
-from zope.event import notify
-from zope.processlifetime import DatabaseOpened
-
 app = None
 startup_time = asctime()
 
@@ -92,7 +91,7 @@
         from ZODB.ActivityMonitor import ActivityMonitor
         DB.setActivityMonitor(ActivityMonitor())
 
-    Globals.DB = DB # Ick, this is temporary until we come up with some registry
+    Globals.DB = DB
     Zope2.DB = DB
 
     # Hook for providing multiple transaction object manager undo support:
@@ -105,6 +104,14 @@
     # "Log on" as system user
     newSecurityManager(None, AccessControl.User.system)
 
+    # Set up the CA
+    from .zcml import load_site
+    load_site()
+
+    # Set up Zope2 specific vocabulary registry
+    from .schema import Zope2VocabularyRegistry
+    setVocabularyRegistry(Zope2VocabularyRegistry())
+
     # Set up the "app" object that automagically opens
     # connections
     app = App.ZApplication.ZApplicationWrapper(
@@ -138,8 +145,11 @@
 
 
 class RequestContainer(ExtensionClass.Base):
-    def __init__(self,r): self.REQUEST=r
 
+    def __init__(self, r):
+        self.REQUEST=r
+
+
 class ZPublisherExceptionHook:
 
     def __init__(self):
@@ -215,7 +225,7 @@
                 return response
 
             if (published is None or published is app or
-                type(published) is ListType):
+                isinstance(published, list)):
                 # At least get the top-level object
                 published=app.__bobo_traverse__(REQUEST).__of__(
                     RequestContainer(REQUEST))

Copied: Zope/trunk/src/Zope2/App/zcml.py (from rev 110303, Zope/trunk/src/Products/Five/zcml.py)
===================================================================
--- Zope/trunk/src/Zope2/App/zcml.py	                        (rev 0)
+++ Zope/trunk/src/Zope2/App/zcml.py	2010-03-30 21:14:23 UTC (rev 110339)
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""ZCML machinery
+"""
+
+import os
+import os.path
+from zope.configuration import xmlconfig
+
+_initialized = False
+_context = None
+
+
+def load_site(force=False):
+    """Load a Zope site by finding and loading the appropriate site
+    configuration file."""
+    global _initialized
+    if _initialized and not force:
+        return
+    _initialized = True
+
+    import Globals
+    Globals.INSTANCE_HOME
+
+    # load instance site configuration file
+    site_zcml = os.path.join(Globals.INSTANCE_HOME, "etc", "site.zcml")
+
+    if not os.path.exists(site_zcml):
+        # check for zope installation home skel during running unit tests
+        import Zope2.utilities
+        zope_utils = os.path.dirname(Zope2.utilities.__file__)
+        site_zcml = os.path.join(zope_utils, "skel", "etc", "site.zcml")
+
+    global _context
+    _context = xmlconfig.file(site_zcml)
+
+
+def load_config(config, package=None, execute=True):
+    """Load an additional ZCML file into the context.
+
+    Use with extreme care.
+    """
+    global _context
+    _context = xmlconfig.file(config, package, _context, execute=execute)
+
+
+def load_string(s):
+    """Load a snipped of ZCML into the context.
+
+    Use with extreme care.
+    """
+    global _context
+    _context = xmlconfig.string(s, _context)
+
+
+# clean up code
+
+def cleanUp():
+    global _context
+    _context = None
+
+
+from zope.testing.cleanup import addCleanUp
+addCleanUp(cleanUp)
+del addCleanUp



More information about the Zope-Checkins mailing list