[Zope-Checkins] SVN: Zope/trunk/ Removed the last remaining code to support `SOFTWARE_HOME` and `ZOPE_HOME`.
Hanno Schlichting
hannosch at hannosch.eu
Sun Jul 3 11:19:22 EDT 2011
Log message for revision 122084:
Removed the last remaining code to support `SOFTWARE_HOME` and `ZOPE_HOME`.
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/App/ApplicationManager.py
U Zope/trunk/src/App/Extensions.py
U Zope/trunk/src/App/FindHomes.py
U Zope/trunk/src/App/ImageFile.py
U Zope/trunk/src/App/config.py
U Zope/trunk/src/App/special_dtml.py
U Zope/trunk/src/App/tests/test_ApplicationManager.py
D Zope/trunk/src/App/tests/test_Extensions.py
U Zope/trunk/src/App/tests/test_setConfiguration.py
U Zope/trunk/src/OFS/ObjectManager.py
U Zope/trunk/src/Testing/ZopeTestCase/doc/ENVIRONMENT.txt
U Zope/trunk/src/Testing/ZopeTestCase/doc/TIMELINES.txt
U Zope/trunk/src/Zope2/Startup/datatypes.py
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/doc/CHANGES.rst 2011-07-03 15:19:22 UTC (rev 122084)
@@ -41,6 +41,8 @@
Restructuring
+++++++++++++
+- Removed the last remaining code to support `SOFTWARE_HOME` and `ZOPE_HOME`.
+
- Removed ZMI controls for restarting the process, these no longer apply when
managed as a WSGI application.
Modified: Zope/trunk/src/App/ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/ApplicationManager.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/ApplicationManager.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -239,8 +239,6 @@
InitializeClass(DebugManager)
-
-
class ApplicationManager(Folder, CacheManager):
"""System management
"""
@@ -350,41 +348,6 @@
REQUEST['URL1'] + '/manage_workspace')
return t
- def revert_points(self):
- return ()
-
- def version_list(self):
- # Return a list of currently installed products/versions
- cfg = getConfiguration()
- product_dir = os.path.join(cfg.softwarehome,'Products')
- product_names = os.listdir(product_dir)
- product_names.sort()
- info = []
- for product_name in product_names:
- package_dir = os.path.join(product_dir, product_name)
- if not os.path.isdir(package_dir):
- continue
- version_txt = None
- for name in ('VERSION.TXT', 'VERSION.txt', 'version.txt'):
- v = os.path.join(package_dir, name)
- if os.path.exists(v):
- version_txt = v
- break
- if version_txt is not None:
- file = open(version_txt, 'r')
- data = file.readline()
- file.close()
- info.append(data.strip())
- return info
-
- def getSOFTWARE_HOME(self):
- cfg = getConfiguration()
- return getattr(cfg, 'softwarehome', None)
-
- def getZOPE_HOME(self):
- cfg = getConfiguration()
- return getattr(cfg, 'zopehome', None)
-
def getINSTANCE_HOME(self):
return getConfiguration().instancehome
@@ -406,23 +369,7 @@
l.append((str(type), 'Port: %s' % port))
return l
- def objectIds(self, spec=None):
- """ this is a patch for pre-2.4 Zope installations. Such
- installations don't have an entry for the WebDAV LockManager
- introduced in 2.4.
- """
- meta_types = map(lambda x: x.get('meta_type', None), self._objects)
-
- if not self.DavLocks.meta_type in meta_types:
-
- lst = list(self._objects)
- lst.append({'id': 'DavLocks',
- 'meta_type': self.DavLocks.meta_type})
- self._objects = tuple(lst)
-
- return Folder.objectIds(self, spec)
-
class AltDatabaseManager(DatabaseManager, CacheManager):
""" Database management DBTab-style
"""
Modified: Zope/trunk/src/App/Extensions.py
===================================================================
--- Zope/trunk/src/App/Extensions.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/Extensions.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -12,7 +12,7 @@
##############################################################################
"""Standard routines for handling extensions.
-Extensions currently include external methods and pluggable brains.
+Extensions currently include external methods.
"""
import imp
import os
@@ -90,7 +90,6 @@
raise ValueError('The file name, %s, should be a simple file name'
% name)
- result = None
if checkProduct:
dot = name.find('.')
if dot > 0:
@@ -113,11 +112,6 @@
locations = [cfg.instancehome]
- softwarehome = getattr(cfg, 'softwarehome', None)
- if softwarehome is not None:
- zopehome = os.path.dirname(softwarehome)
- locations.append(zopehome)
-
for home in locations:
found = _getPath(home, prefix, name, suffixes)
if found is not None:
@@ -202,23 +196,3 @@
except KeyError:
raise NotFound("The specified object, '%s', was not found "
"in module, '%s'." % (name, module))
-
-class NoBrains:
- pass
-
-
-def getBrain(module, class_name, reload=0, modules=None):
- """ Check/load a class from an extension.
- """
- if not module and not class_name:
- return NoBrains
-
- if modules is None:
- c=getObject(module, class_name, reload)
- else:
- c=getObject(module, class_name, reload, modules=modules)
-
- if getattr(c, '__bases__', None) is None:
- raise ValueError('%s, is not a class' % class_name)
-
- return c
Modified: Zope/trunk/src/App/FindHomes.py
===================================================================
--- Zope/trunk/src/App/FindHomes.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/FindHomes.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -19,22 +19,6 @@
import Products
try:
- home = os.environ['SOFTWARE_HOME']
-except KeyError:
- pass
-else:
- home = os.path.realpath(home)
- __builtin__.SOFTWARE_HOME = SOFTWARE_HOME = home
-
-try:
- zhome = os.environ['ZOPE_HOME']
-except KeyError:
- pass
-else:
- zhome = os.path.realpath(zhome)
- __builtin__.ZOPE_HOME = ZOPE_HOME = zhome
-
-try:
chome = os.environ['INSTANCE_HOME']
except KeyError:
import Zope2
Modified: Zope/trunk/src/App/ImageFile.py
===================================================================
--- Zope/trunk/src/App/ImageFile.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/ImageFile.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -47,7 +47,7 @@
def __init__(self, path, _prefix=None):
if _prefix is None:
- _prefix=getattr(getConfiguration(), 'softwarehome', None) or PREFIX
+ _prefix = PREFIX
if not os.path.isabs(path):
warnings.warn(NON_PREFIX_WARNING, UserWarning, 2)
elif type(_prefix) is not type(''):
Modified: Zope/trunk/src/App/config.py
===================================================================
--- Zope/trunk/src/App/config.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/config.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -52,16 +52,6 @@
os.environ["INSTANCE_HOME"] = cfg.instancehome
Globals.INSTANCE_HOME = cfg.instancehome
- if hasattr(cfg, 'softwarehome') and cfg.softwarehome is not None:
- __builtin__.SOFTWARE_HOME = FindHomes.SOFTWARE_HOME = cfg.softwarehome
- os.environ["SOFTWARE_HOME"] = cfg.softwarehome
- Globals.SOFTWARE_HOME = cfg.softwarehome
-
- if hasattr(cfg, 'zopehome') and cfg.zopehome is not None:
- __builtin__.ZOPE_HOME = FindHomes.ZOPE_HOME = cfg.zopehome
- os.environ["ZOPE_HOME"] = cfg.zopehome
- Globals.ZOPE_HOME = cfg.zopehome
-
Globals.DevelopmentMode = cfg.debug_mode
class DefaultConfiguration:
@@ -72,10 +62,6 @@
from App import FindHomes
self.clienthome = FindHomes.CLIENT_HOME
self.instancehome = FindHomes.INSTANCE_HOME
- if hasattr(FindHomes, 'SOFTWARE_HOME'):
- self.softwarehome = FindHomes.SOFTWARE_HOME
- if hasattr(FindHomes, 'ZOPE_HOME'):
- self.zopehome = FindHomes.ZOPE_HOME
self.dbtab = None
self.debug_mode = True
self.enable_product_installation = False
Modified: Zope/trunk/src/App/special_dtml.py
===================================================================
--- Zope/trunk/src/App/special_dtml.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/special_dtml.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -45,7 +45,7 @@
def __init__(self, name, _prefix=None, **kw):
if _prefix is None:
- _prefix = getattr(getConfiguration(), 'softwarehome', PREFIX)
+ _prefix = PREFIX
elif type(_prefix) is not type(''):
_prefix = Common.package_home(_prefix)
args=(self, os.path.join(_prefix, name + '.dtml'))
Modified: Zope/trunk/src/App/tests/test_ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/tests/test_ApplicationManager.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/tests/test_ApplicationManager.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -414,50 +414,6 @@
am = self._makeOne()
self.assertEqual(am.thread_get_ident(), thread.get_ident())
- def test_revert_points(self):
- am = self._makeOne()
- self.assertEqual(list(am.revert_points()), [])
-
- def test_version_list(self):
- # XXX this method is too stupid to live: returning a bare list
- # of versions without even tying them to the products?
- # and what about products living outside SOFTWARE_HOME?
- # Nobody calls it, either
- import os
- am = self._makeOne()
- config = self._makeConfig()
- swdir = config.softwarehome = self._makeTempdir()
- foodir = os.path.join(swdir, 'Products', 'foo')
- self._makeFile(foodir, 'VERSION.TXT', '1.2')
- bardir = os.path.join(swdir, 'Products', 'bar')
- self._makeFile(bardir, 'VERSION.txt', '3.4')
- bazdir = os.path.join(swdir, 'Products', 'baz')
- self._makeFile(bazdir, 'version.txt', '5.6')
- versions = am.version_list()
- self.assertEqual(versions, ['3.4', '5.6', '1.2'])
-
- def test_getSOFTWARE_HOME_missing(self):
- am = self._makeOne()
- config = self._makeConfig()
- self.assertEqual(am.getSOFTWARE_HOME(), None)
-
- def test_getSOFTWARE_HOME_present(self):
- am = self._makeOne()
- config = self._makeConfig()
- swdir = config.softwarehome = self._makeTempdir()
- self.assertEqual(am.getSOFTWARE_HOME(), swdir)
-
- def test_getZOPE_HOME_missing(self):
- am = self._makeOne()
- config = self._makeConfig()
- self.assertEqual(am.getZOPE_HOME(), None)
-
- def test_getZOPE_HOME_present(self):
- am = self._makeOne()
- config = self._makeConfig()
- zopedir = config.zopehome = self._makeTempdir()
- self.assertEqual(am.getZOPE_HOME(), zopedir)
-
def test_getINSTANCE_HOME(self):
am = self._makeOne()
config = self._makeConfig()
Deleted: Zope/trunk/src/App/tests/test_Extensions.py
===================================================================
--- Zope/trunk/src/App/tests/test_Extensions.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/tests/test_Extensions.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -1,425 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Zope Foundation and Contributors.
-#
-# 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
-#
-##############################################################################
-""" Unit tests for App.Extensions module
-"""
-import unittest
-
-
-class FuncCodeTests(unittest.TestCase):
-
- def _getTargetClass(self):
- from App.Extensions import FuncCode
- return FuncCode
-
- def _makeOne(self, f, im=0):
- return self._getTargetClass()(f, im)
-
- def test_ctor_not_method_no_args(self):
- def f():
- pass
- fc = self._makeOne(f)
- self.assertEqual(fc.co_varnames, ())
- self.assertEqual(fc.co_argcount, 0)
-
- def test_ctor_not_method_w_args(self):
- def f(a, b):
- pass
- fc = self._makeOne(f)
- self.assertEqual(fc.co_varnames, ('a', 'b'))
- self.assertEqual(fc.co_argcount, 2)
-
- def test_ctor_w_method_no_args(self):
- def f(self):
- pass
- fc = self._makeOne(f, im=1)
- self.assertEqual(fc.co_varnames, ())
- self.assertEqual(fc.co_argcount, 0)
-
- def test_ctor_w_method_w_args(self):
- def f(self, a, b):
- pass
- fc = self._makeOne(f, im=1)
- self.assertEqual(fc.co_varnames, ('a', 'b'))
- self.assertEqual(fc.co_argcount, 2)
-
- def test___cmp___None(self):
- def f(self):
- pass
- fc = self._makeOne(f, im=1)
- self.assertTrue(cmp(fc, None) > 0)
-
- def test___cmp___non_FuncCode(self):
- def f(self):
- pass
- fc = self._makeOne(f, im=1)
- self.assertTrue(cmp(fc, object()) > 0)
-
- def test___cmp___w_FuncCode_same_args(self):
- def f(self, a, b):
- pass
- def g(self, a, b):
- pass
- fc = self._makeOne(f, im=1)
- fc2 = self._makeOne(g, im=1)
- self.assertTrue(cmp(fc, fc2) == 0)
-
- def test___cmp___w_FuncCode_different_args(self):
- def f(self):
- pass
- def g(self, a, b):
- pass
- fc = self._makeOne(f, im=1)
- fc2 = self._makeOne(g, im=1)
- self.assertTrue(cmp(fc, fc2) < 0)
-
-
-class _TempdirBase:
-
- _old_Products___path__ = None
- _tmpdirs = ()
- _old_sys_path = None
- _added_path = None
-
- def tearDown(self):
- import shutil
- if self._old_Products___path__ is not None:
- import Products
- Products.__path__ = self._old_Products___path__
- for tmpdir in self._tmpdirs:
- shutil.rmtree(tmpdir)
- if self._old_sys_path is not None:
- import sys
- sys.path[:] = self._old_sys_path
- for k, v in sys.modules.items():
- if getattr(v, '__file__', '').startswith(self._added_path):
- del sys.modules[k]
-
- def _makeTempdir(self):
- import tempfile
- tmp = tempfile.mkdtemp()
- self._tmpdirs += (tmp,)
- return tmp
-
- def _makePathDir(self):
- import sys
- dir = self._makeTempdir()
- self._old_sys_path = sys.path[:]
- sys.path.insert(0, dir)
- self._added_path = dir
- return dir
-
- def _makeTempExtension(self, name='foo', extname='Extensions', dir=None):
- import os
- if dir is None:
- dir = self._makeTempdir()
- if name is None:
- extdir = os.path.join(dir, extname)
- else:
- extdir = os.path.join(dir, name, extname)
- os.makedirs(extdir)
- return extdir
-
- def _makeTempProduct(self, name='foo', extname='Extensions'):
- import Products
- self._old_Products___path__ = Products.__path__[:]
- root = self._makeTempdir()
- pdir = self._makeTempExtension(name=name, extname=extname, dir=root)
- Products.__path__ = (root,)
- return pdir
-
- def _makeFile(self, dir, name, text='#extension'):
- import os
- fqn = os.path.join(dir, name)
- f = open(fqn, 'w')
- f.write(text)
- f.flush()
- f.close()
- return fqn
-
-
-class Test_getPath(_TempdirBase, unittest.TestCase):
-
- def _callFUT(self, prefix, name, checkProduct=1, suffixes=('',), cfg=None):
- from App.Extensions import getPath
- return getPath(prefix, name, checkProduct, suffixes, cfg)
-
- def _makeConfig(self, **kw):
- class DummyConfig:
- def __init__(self, **kw):
- self.__dict__.update(kw)
- return DummyConfig(**kw)
-
- def test_name_as_path_raises(self):
- self.assertRaises(ValueError, self._callFUT, 'Extensions', 'foo/bar')
-
- def test_found_in_product(self):
- instdir = self._makeTempdir()
- swdir = self._makeTempdir()
- cfg = self._makeConfig(instancehome=instdir,
- softwarehome=swdir,
- )
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py')
- path = self._callFUT('Extensions', 'foo.extension',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, ext)
-
- def test_not_found_in_product(self):
- instdir = self._makeTempdir()
- swdir = self._makeTempdir()
- cfg = self._makeConfig(instancehome=instdir,
- softwarehome=swdir,
- )
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py')
- path = self._callFUT('Extensions', 'foo.other',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, None)
-
- def test_wo_checkProduct_skips_product(self):
- import Products
- self._old_Products___path__ = Products.__path__
- del Products.__path__ # so any iteration will raise
- instdir = self._makeTempdir()
- instext = self._makeTempExtension(name=None, dir=instdir)
- instfqn = self._makeFile(instext, 'extension.py')
- swdir = self._makeTempdir()
- swext = self._makeTempExtension(name=None, dir=swdir)
- swfqn = self._makeFile(swext, 'extension.py')
- cfg = self._makeConfig(instancehome=instdir,
- softwarehome=swdir,
- )
- path = self._callFUT('Extensions', 'extension', checkProduct=0,
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, instfqn)
-
- def test_w_cfg_extensions(self):
- cfgdir = self._makeTempdir()
- cfgfqn = self._makeFile(cfgdir, 'extension.py')
- instdir = self._makeTempdir()
- instext = self._makeTempExtension(name=None, dir=instdir)
- instfqn = self._makeFile(instext, 'extension.py')
- swdir = self._makeTempdir()
- swext = self._makeTempExtension(name=None, dir=swdir)
- swfqn = self._makeFile(swext, 'extension.py')
- cfg = self._makeConfig(extensions=cfgdir,
- instancehome=instdir,
- softwarehome=swdir,
- )
- path = self._callFUT('Extensions', 'extension', checkProduct=0,
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, cfgfqn)
-
- def test_not_found_in_instancehome(self):
- import os
- instdir = self._makeTempdir()
- zopedir = self._makeTempdir()
- swdir = os.path.join(zopedir, 'src')
- os.mkdir(swdir)
- zopeext = self._makeTempExtension(name=None, dir=zopedir)
- zopefqn = self._makeFile(zopeext, 'extension.py')
- cfg = self._makeConfig(instancehome=instdir,
- softwarehome=swdir,
- )
- path = self._callFUT('Extensions', 'extension',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, zopefqn)
-
- def test_no_swhome(self):
- instdir = self._makeTempdir()
- cfg = self._makeConfig(instancehome=instdir,
- )
- extdir = self._makeTempProduct()
- path = self._callFUT('Extensions', 'extension',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, None)
-
- def test_search_via_import_one_dot(self):
- import os
- instdir = self._makeTempdir()
- cfg = self._makeConfig(instancehome=instdir,
- )
- pathdir = self._makePathDir()
- pkgdir = os.path.join(pathdir, 'somepkg')
- os.mkdir(pkgdir)
- self._makeFile(pkgdir, '__init__.py', '#package')
- pkgext = self._makeTempExtension(name=None, dir=pkgdir)
- pkgfqn = self._makeFile(pkgext, 'extension.py')
- path = self._callFUT('Extensions', 'somepkg.extension',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, pkgfqn)
-
- def test_search_via_import_multiple_dots(self):
- import os
- instdir = self._makeTempdir()
- cfg = self._makeConfig(instancehome=instdir,
- )
- pathdir = self._makePathDir()
- pkgdir = os.path.join(pathdir, 'somepkg')
- os.mkdir(pkgdir)
- self._makeFile(pkgdir, '__init__.py', '#package')
- subpkgdir = os.path.join(pkgdir, 'subpkg')
- os.mkdir(subpkgdir)
- self._makeFile(subpkgdir, '__init__.py', '#subpackage')
- subpkgext = self._makeTempExtension(name=None, dir=subpkgdir)
- subpkgfqn = self._makeFile(subpkgext, 'extension.py')
- path = self._callFUT('Extensions', 'somepkg.subpkg.extension',
- suffixes=('py',), cfg=cfg)
- self.assertEqual(path, subpkgfqn)
-
-"""
-Index: lib/python/App/Extensions.py
-===================================================================
---- lib/python/App/Extensions.py (revision 28473)
-+++ lib/python/App/Extensions.py (working copy)
-@@ -87,8 +87,14 @@
- r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes)
- if r is not None: return r
-
-+
- import App.config
- cfg = App.config.getConfiguration()
-+
-+ if (prefix=="Extensions") and (cfg.extensions is not None):
-+ r=_getPath(cfg.extensions, '', name, suffixes)
-+ if r is not None: return r
-+
- sw=os.path.dirname(os.path.dirname(cfg.softwarehome))
- for home in (cfg.instancehome, sw):
- r=_getPath(home, prefix, name, suffixes)
-"""
-
-class Test_getObject(_TempdirBase, unittest.TestCase):
-
- def _callFUT(self, module, name, reload=0, modules=None):
- from App.Extensions import getObject
- if modules is not None:
- return getObject(module, name, reload, modules)
- return getObject(module, name, reload)
-
- def test_cache_miss(self):
- from zExceptions import NotFound
- MODULES = {'somemodule': {}}
- self.assertRaises(NotFound,
- self._callFUT, 'somemodule', 'name', modules=MODULES)
-
- def test_cache_hit(self):
- obj = object()
- MODULES = {'somemodule': {'name': obj}}
- found = self._callFUT('somemodule', 'name', modules=MODULES)
- self.assertTrue(found is obj)
-
- def test_no_such_module(self):
- from zExceptions import NotFound
- MODULES = {}
- self.assertRaises(NotFound, self._callFUT,
- 'nonesuch', 'name', modules=MODULES)
- self.assertFalse('nonesuch' in MODULES)
-
- def test_not_found_in_module(self):
- from zExceptions import NotFound
- MODULES = {}
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py')
- self.assertRaises(NotFound, self._callFUT,
- 'foo.extension', 'name', modules=MODULES)
- self.assertTrue('foo.extension' in MODULES)
- self.assertFalse('named' in MODULES['foo.extension'])
-
- def test_found_in_module(self):
- MODULES = {}
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py', EXTENSION_PY)
- found = self._callFUT('foo.extension', 'named', modules=MODULES)
- self.assertEqual(found, 'NAMED')
- self.assertTrue('foo.extension' in MODULES)
- self.assertEqual(MODULES['foo.extension']['named'], 'NAMED')
-
- def test_found_in_module_pyc(self):
- from compileall import compile_dir
- import os
- MODULES = {}
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py', EXTENSION_PY)
- compile_dir(extdir, quiet=1)
- os.remove(ext)
- found = self._callFUT('foo.extension', 'named', modules=MODULES)
- self.assertEqual(found, 'NAMED')
- self.assertTrue('foo.extension' in MODULES)
- self.assertEqual(MODULES['foo.extension']['named'], 'NAMED')
-
- def test_found_in_module_after_cache_miss(self):
- cached = {}
- MODULES = {'foo.extension': cached}
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py', EXTENSION_PY)
- found = self._callFUT('foo.extension', 'named', modules=MODULES)
- self.assertEqual(found, 'NAMED')
- self.assertEqual(cached['named'], 'NAMED')
-
- def test_found_in_module_after_cache_hit_but_reload(self):
- cached = {'named': 'BEFORE'}
- MODULES = {'foo.extension': cached}
- extdir = self._makeTempProduct()
- ext = self._makeFile(extdir, 'extension.py', EXTENSION_PY)
- found = self._callFUT('foo.extension', 'named', reload=1,
- modules=MODULES)
- self.assertEqual(found, 'NAMED')
- self.assertEqual(cached['named'], 'NAMED')
-
-
-class Test_getBrain(_TempdirBase, unittest.TestCase):
-
- def _callFUT(self, module, name, reload=0, modules=None):
- from App.Extensions import getBrain
- if modules is not None:
- return getBrain(module, name, reload, modules)
- return getBrain(module, name, reload)
-
- def test_no_module_no_class_yields_NoBrains(self):
- from App.Extensions import NoBrains
- self.assertTrue(self._callFUT('', '') is NoBrains)
-
- def test_missing_name(self):
- from App.Extensions import NoBrains
- from zExceptions import NotFound
- self.assertTrue(self._callFUT('', '') is NoBrains)
- MODULES = {'somemodule': {}}
- self.assertRaises(NotFound,
- self._callFUT, 'somemodule', 'name', modules=MODULES)
-
- def test_not_a_class(self):
- from App.Extensions import NoBrains
- self.assertTrue(self._callFUT('', '') is NoBrains)
- MODULES = {'somemodule': {'name': object()}}
- self.assertRaises(ValueError,
- self._callFUT, 'somemodule', 'name', modules=MODULES)
-
- def test_found_class(self):
- from App.Extensions import NoBrains
- self.assertTrue(self._callFUT('', '') is NoBrains)
- MODULES = {'somemodule': {'name': self.__class__}}
- self.assertEqual(self._callFUT('somemodule', 'name', modules=MODULES),
- self.__class__)
-
-EXTENSION_PY = """\
-named = 'NAMED'
-"""
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(FuncCodeTests),
- unittest.makeSuite(Test_getPath),
- unittest.makeSuite(Test_getObject),
- unittest.makeSuite(Test_getBrain),
- ))
Modified: Zope/trunk/src/App/tests/test_setConfiguration.py
===================================================================
--- Zope/trunk/src/App/tests/test_setConfiguration.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/App/tests/test_setConfiguration.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -26,15 +26,11 @@
# Save away everything as we need to restore it later on
self.clienthome = self.getconfig('clienthome')
self.instancehome = self.getconfig('instancehome')
- self.softwarehome = self.getconfig('softwarehome')
- self.zopehome = self.getconfig('zopehome')
self.debug_mode = self.getconfig('debug_mode')
def tearDown(self):
self.setconfig(clienthome=self.clienthome,
instancehome=self.instancehome,
- softwarehome=self.softwarehome,
- zopehome=self.zopehome,
debug_mode=self.debug_mode)
def getconfig(self, key):
@@ -71,28 +67,6 @@
self.assertEqual(__builtin__.INSTANCE_HOME, 'foo')
self.assertEqual(Globals.INSTANCE_HOME, 'foo')
- def testSoftwareHomeLegacySources(self):
- import os
- import App.FindHomes
- import Globals # for data
- import __builtin__
- self.setconfig(softwarehome='foo')
- self.assertEqual(os.environ.get('SOFTWARE_HOME'), 'foo')
- self.assertEqual(App.FindHomes.SOFTWARE_HOME, 'foo')
- self.assertEqual(__builtin__.SOFTWARE_HOME, 'foo')
- self.assertEqual(Globals.SOFTWARE_HOME, 'foo')
-
- def testZopeHomeLegacySources(self):
- import os
- import App.FindHomes
- import Globals # for data
- import __builtin__
- self.setconfig(zopehome='foo')
- self.assertEqual(os.environ.get('ZOPE_HOME'), 'foo')
- self.assertEqual(App.FindHomes.ZOPE_HOME, 'foo')
- self.assertEqual(__builtin__.ZOPE_HOME, 'foo')
- self.assertEqual(Globals.ZOPE_HOME, 'foo')
-
def testDebugModeLegacySources(self):
import Globals # for data
self.setconfig(debug_mode=True)
Modified: Zope/trunk/src/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/ObjectManager.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/OFS/ObjectManager.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -639,9 +639,6 @@
def _getImportPaths(self):
cfg = getConfiguration()
paths = []
- zopehome = getattr(cfg, 'zopehome', None)
- if zopehome is not None and cfg.zopehome is not None:
- paths.append(zopehome)
if not cfg.instancehome in paths:
paths.append(cfg.instancehome)
if not cfg.clienthome in paths:
Modified: Zope/trunk/src/Testing/ZopeTestCase/doc/ENVIRONMENT.txt
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/doc/ENVIRONMENT.txt 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/Testing/ZopeTestCase/doc/ENVIRONMENT.txt 2011-07-03 15:19:22 UTC (rev 122084)
@@ -2,12 +2,11 @@
ZTC makes the following assumptions about its environment:
a) The 'ZopeTestCase' package is installed in the Zope "trunk" inside the
- 'Testing' module, which means: SOFTWARE_HOME/Testing/ZopeTestCase.
+ 'Testing' module.
-b) A 'Products' directory exists inside SOFTWARE_HOME and INSTANCE_HOME.
+b) none
-c) The tests (the 'tests' subdirectories) are located either below a
- SOFTWARE_HOME or INSTANCE_HOME, typically in Products/MyCoolProduct/tests.
+c) none
d) The somewhat weak assumption is that ZTC can walk up the directory tree from
'tests', and find a 'Products' directory. This is how INSTANCE_HOME
@@ -23,9 +22,8 @@
2) INSTANCE_HOME/custom_zodb.py must be used to set up a ZODB.
-ZTC attempts to resolve this by detecting an INSTANCE_HOME for 1) but leaving
-the actual environment variable untouched so 2) works by still pointing into
-SOFTWARE_HOME/Testing.
+ZTC attempts to resolve this by detecting an INSTANCE_HOME but leaving
+the actual environment variable untouched
As soon as I allow you to set INSTANCE_HOME yourself, I lose the ability to
distinguish whether you mean 1) or 2) or both.
Modified: Zope/trunk/src/Testing/ZopeTestCase/doc/TIMELINES.txt
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/doc/TIMELINES.txt 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/Testing/ZopeTestCase/doc/TIMELINES.txt 2011-07-03 15:19:22 UTC (rev 122084)
@@ -5,7 +5,6 @@
1. includes file framework.py
1.1 locates and imports the Testing package by means of
- - SOFTWARE_HOME environment variable
- auto-detection
1.2 locates and includes file ztc_common.py
Modified: Zope/trunk/src/Zope2/Startup/datatypes.py
===================================================================
--- Zope/trunk/src/Zope2/Startup/datatypes.py 2011-07-03 15:00:45 UTC (rev 122083)
+++ Zope/trunk/src/Zope2/Startup/datatypes.py 2011-07-03 15:19:22 UTC (rev 122084)
@@ -115,16 +115,11 @@
return self.data
# Datatype for the root configuration object
-# (adds the softwarehome and zopehome fields; default values for some
-# computed paths, configures the dbtab)
+# (default values for some computed paths, configures the dbtab)
def root_config(section):
from ZConfig import ConfigurationError
from ZConfig.matcher import SectionValue
- here = os.path.dirname(os.path.abspath(__file__))
- swhome = os.path.dirname(os.path.dirname(here))
- section.softwarehome = swhome
- section.zopehome = os.path.dirname(os.path.dirname(swhome))
if section.environment is None:
section.environment = zdaemonEnvironDict()
if section.cgi_environment is None:
More information about the Zope-Checkins
mailing list