[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ Collector #1798, issue 1: ZopeTestCase no longer tries to

2005-06-10 Thread Stefan H. Holek
Log message for revision 30728:
  Collector #1798, issue 1: ZopeTestCase no longer tries to
  install products that were installed by Zope during startup.
  
  Interestingly, I never saw a checkin message for the merge of
  Lennart's branch...
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/OFS/Application.py
  U   Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py
  U   
Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/utils.py
  U   
Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2005-06-10 08:54:29 UTC 
(rev 30727)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2005-06-10 10:05:01 UTC 
(rev 30728)
@@ -31,7 +31,7 @@
   - Collector #1803: Fixed InitializeClass for some corner case.
 
   - Collector #1798, issue 1: ZopeTestCase no longer tries to 
-install products that was installed by Zope during startup.
+install products that were installed by Zope during startup.
 
   - Collector #1799: Avoid lying about parent's refcount when
 calling back into Python code.

Modified: Zope/branches/Zope-2_8-branch/lib/python/OFS/Application.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/OFS/Application.py 2005-06-10 
08:54:29 UTC (rev 30727)
+++ Zope/branches/Zope-2_8-branch/lib/python/OFS/Application.py 2005-06-10 
10:05:01 UTC (rev 30728)
@@ -38,9 +38,6 @@
 import ZDOM
 from FindSupport import FindSupport
 
-# Dictionary of installed products, mainly used by ZopeTestCase.
-_installedProducts = {}
-
 class Application(Globals.ApplicationDefaultPermissions,
   ZDOM.Root, Folder.Folder,
   App.ProductRegistry.ProductRegistry, FindSupport):
@@ -624,13 +621,7 @@
 # together and do a default initialization.
 if done.has_key(product_name):
 continue
-# We need to separately track what has been installed now, and
-# what has been installed at a whole. This is because install_products
-# should always install everything, but only once every time it's 
-# called. The _installedProducts dictionary is later used by 
-# ZopeTestCase to not install products twice.
 done[product_name]=1
-_installedProducts[product_name]=1
 install_product(app, product_dir, product_name, meta_types,
 folder_permissions, raise_exc=debug_mode)
 

Modified: 
Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py   
2005-06-10 08:54:29 UTC (rev 30727)
+++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py   
2005-06-10 10:05:01 UTC (rev 30728)
@@ -99,6 +99,8 @@
 import App.ProductContext
 _write('.')
 
+_patched = False
+
 def _apply_patches():
 # Avoid expensive product import
 def null_import_products(): pass
@@ -116,18 +118,22 @@
 def null_register_help(self,directory='',clear=1,title_re=None): pass
 App.ProductContext.ProductContext.registerHelp = null_register_help
 
+# Note that we applied the monkey patches
+global _patched
+_patched = True
+
 # Do not patch a running Zope
 if not Zope2._began_startup:
 _apply_patches()
 
 # Allow test authors to install Zope products into the test environment. Note
 # that installProduct() must be called at module level -- never from tests.
-from OFS.Application import get_folder_permissions, get_products, \
- install_product, _installedProducts
+from OFS.Application import get_folder_permissions, get_products, 
install_product
 from OFS.Folder import Folder
 import Products
 
 _theApp = Zope2.app()
+_installedProducts = {}
 
 def hasProduct(name):
 '''Checks if a product can be found along Products.__path__'''
@@ -137,7 +143,7 @@
 '''Installs a Zope product.'''
 start = time.time()
 meta_types = []
-if not _installedProducts.has_key(name):
+if _patched and not _installedProducts.has_key(name):
 for priority, product_name, index, product_dir in get_products():
 if product_name == name:
 if not quiet: _print('Installing %s ... ' % product_name)

Modified: 
Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
===
--- 
Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt   
2005-06-10 08:54:29 UTC (rev 30727)
+++ 

[Zope-Checkins] SVN: Zope/trunk/lib/python/ Collector #1798, issue 1: ZopeTestCase no longer tries to

2005-06-10 Thread Stefan H. Holek
Log message for revision 30729:
  Collector #1798, issue 1: ZopeTestCase no longer tries to
  install products that were installed by Zope during startup.
  

Changed:
  U   Zope/trunk/lib/python/OFS/Application.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
  U   
Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt

-=-
Modified: Zope/trunk/lib/python/OFS/Application.py
===
--- Zope/trunk/lib/python/OFS/Application.py2005-06-10 10:05:01 UTC (rev 
30728)
+++ Zope/trunk/lib/python/OFS/Application.py2005-06-10 10:36:30 UTC (rev 
30729)
@@ -38,9 +38,6 @@
 import ZDOM
 from FindSupport import FindSupport
 
-# Dictionary of installed products, mainly used by ZopeTestCase.
-_installedProducts = {}
-
 class Application(Globals.ApplicationDefaultPermissions,
   ZDOM.Root, Folder.Folder,
   App.ProductRegistry.ProductRegistry, FindSupport):
@@ -624,13 +621,7 @@
 # together and do a default initialization.
 if done.has_key(product_name):
 continue
-# We need to separately track what has been installed now, and
-# what has been installed at a whole. This is because install_products
-# should always install everything, but only once every time it's 
-# called. The _installedProducts dictionary is later used by 
-# ZopeTestCase to not install products twice.
 done[product_name]=1
-_installedProducts[product_name]=1
 install_product(app, product_dir, product_name, meta_types,
 folder_permissions, raise_exc=debug_mode)
 

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py
===
--- Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py  2005-06-10 
10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py  2005-06-10 
10:36:30 UTC (rev 30729)
@@ -99,6 +99,8 @@
 import App.ProductContext
 _write('.')
 
+_patched = False
+
 def _apply_patches():
 # Avoid expensive product import
 def null_import_products(): pass
@@ -116,18 +118,22 @@
 def null_register_help(self,directory='',clear=1,title_re=None): pass
 App.ProductContext.ProductContext.registerHelp = null_register_help
 
+# Note that we applied the monkey patches
+global _patched
+_patched = True
+
 # Do not patch a running Zope
 if not Zope2._began_startup:
 _apply_patches()
 
 # Allow test authors to install Zope products into the test environment. Note
 # that installProduct() must be called at module level -- never from tests.
-from OFS.Application import get_folder_permissions, get_products, \
- install_product, _installedProducts
+from OFS.Application import get_folder_permissions, get_products, 
install_product
 from OFS.Folder import Folder
 import Products
 
 _theApp = Zope2.app()
+_installedProducts = {}
 
 def hasProduct(name):
 '''Checks if a product can be found along Products.__path__'''
@@ -137,7 +143,7 @@
 '''Installs a Zope product.'''
 start = time.time()
 meta_types = []
-if not _installedProducts.has_key(name):
+if _patched and not _installedProducts.has_key(name):
 for priority, product_name, index, product_dir in get_products():
 if product_name == name:
 if not quiet: _print('Installing %s ... ' % product_name)

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
===
--- Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt  2005-06-10 
10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt  2005-06-10 
10:36:30 UTC (rev 30729)
@@ -1,6 +1,8 @@
 Unreleased
 - Functional.publish() would hang if it got a request_method argument other
   than GET or HEAD while omitting the stdin argument.
+- installProduct() now becomes a noop if ZopeTestCase did not apply its
+  patches.
 
 0.9.8 (Zope 2.8 edition)
 - Renamed 'doctest' package to 'zopedoctest' because of name-shadowing

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
===
--- Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2005-06-10 10:05:01 UTC 
(rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2005-06-10 10:36:30 UTC 
(rev 30729)
@@ -97,7 +97,8 @@
 
 def importObjectFromFile(container, filename, quiet=0):
 '''Imports an object from a (.zexp) file into the given container.'''
-from ZopeLite import _print
+from ZopeLite import _print, _patched
+quiet = quiet or not _patched
 start = time.time()
 if not quiet: _print(Importing %s ...  % os.path.basename(filename))