Commit 69b34b13 authored by Stefan H. Holek's avatar Stefan H. Holek

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...
parent 1a87da63
......@@ -31,7 +31,7 @@ Zope Changes
- 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.
......
......@@ -38,9 +38,6 @@ import Folder
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 @@ def install_products(app):
# 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)
......
......@@ -99,6 +99,8 @@ import OFS.Application
import App.ProductContext
_write('.')
_patched = False
def _apply_patches():
# Avoid expensive product import
def null_import_products(): pass
......@@ -116,18 +118,22 @@ def _apply_patches():
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 @@ def installProduct(name, quiet=0):
'''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)
......
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
......
......@@ -97,7 +97,8 @@ def setupSiteErrorLog(app=None):
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))
container._importObjectFromFile(filename, verify=0)
......
......@@ -114,7 +114,7 @@ Test Server Error
... GET /test_folder_1_/script?a=2 HTTP/1.1
... """, handle_errors=False)
HTTP/1.1 500 Internal Server Error
...Content-Type: text/html...exceptions.TypeError...
...Content-Type: text/html...TypeError...
Test Unauthorized
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment