[Zope-Checkins] SVN: Zope/trunk/src/ Also disable product installation in the default test configuration

Hanno Schlichting hannosch at hannosch.eu
Sun Jun 27 07:36:08 EDT 2010


Log message for revision 113923:
  Also disable product installation in the default test configuration
  

Changed:
  U   Zope/trunk/src/App/config.py
  U   Zope/trunk/src/OFS/tests/test_registerpackage.py
  U   Zope/trunk/src/Products/ZODBMountPoint/MountedObject.py
  U   Zope/trunk/src/Products/ZODBMountPoint/__init__.py
  U   Zope/trunk/src/Products/ZODBMountPoint/tests/testMountPoint.py

-=-
Modified: Zope/trunk/src/App/config.py
===================================================================
--- Zope/trunk/src/App/config.py	2010-06-27 11:09:01 UTC (rev 113922)
+++ Zope/trunk/src/App/config.py	2010-06-27 11:36:07 UTC (rev 113923)
@@ -86,7 +86,7 @@
             self.zopehome = FindHomes.ZOPE_HOME
         self.dbtab = None
         self.debug_mode = True
-        self.enable_product_installation = True
+        self.enable_product_installation = False
         self.locale = None
 
         # restructured text

Modified: Zope/trunk/src/OFS/tests/test_registerpackage.py
===================================================================
--- Zope/trunk/src/OFS/tests/test_registerpackage.py	2010-06-27 11:09:01 UTC (rev 113922)
+++ Zope/trunk/src/OFS/tests/test_registerpackage.py	2010-06-27 11:36:07 UTC (rev 113923)
@@ -12,8 +12,6 @@
 #
 ##############################################################################
 """Unit tests for the registerPackage directive.
-
-$Id$
 """
 import sys
 
@@ -50,27 +48,16 @@
       
     We need to load the product as well. This would normally happen during 
     Zope startup, but in the test, we're already too late.
-    
+
       >>> import Zope2
       >>> from OFS.Application import install_products
       
       >>> app = Zope2.app()
       >>> install_products(app)
       pythonproduct2 initialized
-      
-    Test to see if the pythonproduct2 python package actually gets setup
-    as a zope2 product in the Control Panel.
 
-      >>> product_listing = []
-      >>> try:
-      ...    product_listing = app.Control_Panel.Products.objectIds()
-      ... finally:
-      ...     app._p_jar.close()
-      >>> 'pythonproduct2' in product_listing
-      True
+    Make sure it shows up in ``Products._registered_packages``.
 
-    Make sure it also shows up in ``Products._registered_packages``.
-
       >>> [x.__name__ for x in getattr(Products, '_registered_packages', [])]
       ['pythonproduct2']
 

Modified: Zope/trunk/src/Products/ZODBMountPoint/MountedObject.py
===================================================================
--- Zope/trunk/src/Products/ZODBMountPoint/MountedObject.py	2010-06-27 11:09:01 UTC (rev 113922)
+++ Zope/trunk/src/Products/ZODBMountPoint/MountedObject.py	2010-06-27 11:36:07 UTC (rev 113923)
@@ -25,13 +25,13 @@
 import transaction
 
 from AccessControl.class_init import InitializeClass
-from AccessControl.ZopeGuards import guarded_getattr
 from Acquisition import ImplicitAcquisitionWrapper
 from Acquisition import aq_base
 from Acquisition import aq_inner
 from Acquisition import aq_parent
 from OFS.SimpleItem import SimpleItem
 from OFS.Folder import Folder
+from OFS.Folder import manage_addFolder
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
 LOG = getLogger('Zope.ZODBMountPoint')
@@ -55,9 +55,7 @@
 
     def _construct(self, context, id):
         """Creates and returns the named folder."""
-        dispatcher = guarded_getattr(context, 'manage_addProduct')['OFSP']
-        factory = guarded_getattr(dispatcher, 'manage_addFolder')
-        factory(id)
+        manage_addFolder(context, id)
         o = context.restrictedTraverse(id)
         context._p_jar.add(aq_base(o))
         return o
@@ -391,5 +389,3 @@
         REQUEST['RESPONSE'].redirect(
             REQUEST['URL1'] + ('/manage_main?manage_tabs_message='
             'Added %d mount points.' % count))
-
-

Modified: Zope/trunk/src/Products/ZODBMountPoint/__init__.py
===================================================================
--- Zope/trunk/src/Products/ZODBMountPoint/__init__.py	2010-06-27 11:09:01 UTC (rev 113922)
+++ Zope/trunk/src/Products/ZODBMountPoint/__init__.py	2010-06-27 11:36:07 UTC (rev 113923)
@@ -25,6 +25,3 @@
                       MountedObject.manage_getMountStatus,
                       MountedObject.manage_addMounts,),
         )
-
-
-

Modified: Zope/trunk/src/Products/ZODBMountPoint/tests/testMountPoint.py
===================================================================
--- Zope/trunk/src/Products/ZODBMountPoint/tests/testMountPoint.py	2010-06-27 11:09:01 UTC (rev 113922)
+++ Zope/trunk/src/Products/ZODBMountPoint/tests/testMountPoint.py	2010-06-27 11:36:07 UTC (rev 113923)
@@ -15,10 +15,12 @@
 """
 
 import os
+import os.path
 import sys
 import unittest
 import transaction
 from OFS.Application import Application
+from OFS.Application import get_folder_permissions
 from OFS.Folder import Folder
 import App.config
 from Products.ZODBMountPoint.MountedObject import manage_addMounts
@@ -78,7 +80,7 @@
         if original_config is None:
             # stow away original config so we can reset it
             original_config = App.config.getConfiguration()
-            
+
         databases = [TestDBConfig('test_main.fs', ['/']).getDB(),
                      TestDBConfig('test_mount1.fs', ['/mount1']).getDB(),
                      TestDBConfig('test_mount2.fs', ['/mount2']).getDB(),
@@ -95,6 +97,7 @@
         conf = DBTab(mount_factories, mount_points)
         d = App.config.DefaultConfiguration()
         d.dbtab = conf
+        d.enable_product_installation = True
         App.config.setConfiguration(d)
         self.conf = conf
         db = conf.getDatabase('/')
@@ -102,7 +105,9 @@
         root = conn.root()
         root['Application'] = app = Application()
         self.app = app
-        install_products(app, 'ZCatalog', 'PluginIndexes', 'OFSP')
+        install_product(app, 'ZCatalog')
+        install_product(app, 'PluginIndexes')
+        install_product(app, 'OFSP')
         # login
         from AccessControl.User import system
         from AccessControl.SecurityManagement import newSecurityManager
@@ -111,8 +116,6 @@
         manage_addMounts(app, ('/mount1', '/mount2', '/i/mount3'))
         transaction.commit()  # Get the mount points ready
 
-
-
     def tearDown(self):
         # logout
         from AccessControl.SecurityManagement import noSecurityManager
@@ -228,25 +231,13 @@
         self.assertEqual(conn2.opened, None)
         self.assertEqual(conn3.opened, None)
 
-def install_products(app, *prod):
-    """auxiliary function to install products *prod* (by names)."""
-    from OFS.Application import get_folder_permissions, get_products, install_product
 
-    folder_permissions = get_folder_permissions()
-    meta_types=[]
-    done={}
-    products = get_products()
-    for priority, product_name, index, product_dir in products:
-        if product_name not in prod or product_name in done: continue
-        done[product_name]=1
-        install_product(app, product_dir, product_name, meta_types,
-                        folder_permissions, raise_exc=True)
-        
+def install_product(app, product_name):
+    from OFS.Application import install_product
+    product_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
+    install_product(app, product_dir, product_name, [],
+                    get_folder_permissions(), raise_exc=True)
 
 
 def test_suite():
     return unittest.makeSuite(MountingTests, 'test')
-
-if __name__ == '__main__':
-    unittest.main()
-



More information about the Zope-Checkins mailing list