Commit e1276ff7 authored by Hanno Schlichting's avatar Hanno Schlichting

Removed the last remaining code to support `SOFTWARE_HOME` and `ZOPE_HOME`.

parent 31b6b4d9
...@@ -41,6 +41,8 @@ Features Added ...@@ -41,6 +41,8 @@ Features Added
Restructuring 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 - Removed ZMI controls for restarting the process, these no longer apply when
managed as a WSGI application. managed as a WSGI application.
......
...@@ -239,8 +239,6 @@ class DebugManager(Item, Implicit): ...@@ -239,8 +239,6 @@ class DebugManager(Item, Implicit):
InitializeClass(DebugManager) InitializeClass(DebugManager)
class ApplicationManager(Folder, CacheManager): class ApplicationManager(Folder, CacheManager):
"""System management """System management
""" """
...@@ -350,41 +348,6 @@ class ApplicationManager(Folder, CacheManager): ...@@ -350,41 +348,6 @@ class ApplicationManager(Folder, CacheManager):
REQUEST['URL1'] + '/manage_workspace') REQUEST['URL1'] + '/manage_workspace')
return t 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): def getINSTANCE_HOME(self):
return getConfiguration().instancehome return getConfiguration().instancehome
...@@ -406,22 +369,6 @@ class ApplicationManager(Folder, CacheManager): ...@@ -406,22 +369,6 @@ class ApplicationManager(Folder, CacheManager):
l.append((str(type), 'Port: %s' % port)) l.append((str(type), 'Port: %s' % port))
return l 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): class AltDatabaseManager(DatabaseManager, CacheManager):
""" Database management DBTab-style """ Database management DBTab-style
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""Standard routines for handling extensions. """Standard routines for handling extensions.
Extensions currently include external methods and pluggable brains. Extensions currently include external methods.
""" """
import imp import imp
import os import os
...@@ -90,7 +90,6 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None): ...@@ -90,7 +90,6 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
raise ValueError('The file name, %s, should be a simple file name' raise ValueError('The file name, %s, should be a simple file name'
% name) % name)
result = None
if checkProduct: if checkProduct:
dot = name.find('.') dot = name.find('.')
if dot > 0: if dot > 0:
...@@ -113,11 +112,6 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None): ...@@ -113,11 +112,6 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
locations = [cfg.instancehome] 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: for home in locations:
found = _getPath(home, prefix, name, suffixes) found = _getPath(home, prefix, name, suffixes)
if found is not None: if found is not None:
...@@ -202,23 +196,3 @@ def getObject(module, name, reload=0, ...@@ -202,23 +196,3 @@ def getObject(module, name, reload=0,
except KeyError: except KeyError:
raise NotFound("The specified object, '%s', was not found " raise NotFound("The specified object, '%s', was not found "
"in module, '%s'." % (name, module)) "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
...@@ -18,22 +18,6 @@ import sys ...@@ -18,22 +18,6 @@ import sys
import Products 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: try:
chome = os.environ['INSTANCE_HOME'] chome = os.environ['INSTANCE_HOME']
except KeyError: except KeyError:
......
...@@ -47,7 +47,7 @@ class ImageFile(Explicit): ...@@ -47,7 +47,7 @@ class ImageFile(Explicit):
def __init__(self, path, _prefix=None): def __init__(self, path, _prefix=None):
if _prefix is None: if _prefix is None:
_prefix=getattr(getConfiguration(), 'softwarehome', None) or PREFIX _prefix = PREFIX
if not os.path.isabs(path): if not os.path.isabs(path):
warnings.warn(NON_PREFIX_WARNING, UserWarning, 2) warnings.warn(NON_PREFIX_WARNING, UserWarning, 2)
elif type(_prefix) is not type(''): elif type(_prefix) is not type(''):
......
...@@ -52,16 +52,6 @@ def setConfiguration(cfg): ...@@ -52,16 +52,6 @@ def setConfiguration(cfg):
os.environ["INSTANCE_HOME"] = cfg.instancehome os.environ["INSTANCE_HOME"] = cfg.instancehome
Globals.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 Globals.DevelopmentMode = cfg.debug_mode
class DefaultConfiguration: class DefaultConfiguration:
...@@ -72,10 +62,6 @@ class DefaultConfiguration: ...@@ -72,10 +62,6 @@ class DefaultConfiguration:
from App import FindHomes from App import FindHomes
self.clienthome = FindHomes.CLIENT_HOME self.clienthome = FindHomes.CLIENT_HOME
self.instancehome = FindHomes.INSTANCE_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.dbtab = None
self.debug_mode = True self.debug_mode = True
self.enable_product_installation = False self.enable_product_installation = False
......
...@@ -45,7 +45,7 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,): ...@@ -45,7 +45,7 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
def __init__(self, name, _prefix=None, **kw): def __init__(self, name, _prefix=None, **kw):
if _prefix is None: if _prefix is None:
_prefix = getattr(getConfiguration(), 'softwarehome', PREFIX) _prefix = PREFIX
elif type(_prefix) is not type(''): elif type(_prefix) is not type(''):
_prefix = Common.package_home(_prefix) _prefix = Common.package_home(_prefix)
args=(self, os.path.join(_prefix, name + '.dtml')) args=(self, os.path.join(_prefix, name + '.dtml'))
......
...@@ -414,50 +414,6 @@ class ApplicationManagerTests(ConfigTestBase, ...@@ -414,50 +414,6 @@ class ApplicationManagerTests(ConfigTestBase,
am = self._makeOne() am = self._makeOne()
self.assertEqual(am.thread_get_ident(), thread.get_ident()) 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): def test_getINSTANCE_HOME(self):
am = self._makeOne() am = self._makeOne()
config = self._makeConfig() config = self._makeConfig()
......
This diff is collapsed.
...@@ -26,15 +26,11 @@ class SetConfigTests(unittest.TestCase): ...@@ -26,15 +26,11 @@ class SetConfigTests(unittest.TestCase):
# Save away everything as we need to restore it later on # Save away everything as we need to restore it later on
self.clienthome = self.getconfig('clienthome') self.clienthome = self.getconfig('clienthome')
self.instancehome = self.getconfig('instancehome') self.instancehome = self.getconfig('instancehome')
self.softwarehome = self.getconfig('softwarehome')
self.zopehome = self.getconfig('zopehome')
self.debug_mode = self.getconfig('debug_mode') self.debug_mode = self.getconfig('debug_mode')
def tearDown(self): def tearDown(self):
self.setconfig(clienthome=self.clienthome, self.setconfig(clienthome=self.clienthome,
instancehome=self.instancehome, instancehome=self.instancehome,
softwarehome=self.softwarehome,
zopehome=self.zopehome,
debug_mode=self.debug_mode) debug_mode=self.debug_mode)
def getconfig(self, key): def getconfig(self, key):
...@@ -71,28 +67,6 @@ class SetConfigTests(unittest.TestCase): ...@@ -71,28 +67,6 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(__builtin__.INSTANCE_HOME, 'foo') self.assertEqual(__builtin__.INSTANCE_HOME, 'foo')
self.assertEqual(Globals.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): def testDebugModeLegacySources(self):
import Globals # for data import Globals # for data
self.setconfig(debug_mode=True) self.setconfig(debug_mode=True)
......
...@@ -639,9 +639,6 @@ class ObjectManager(CopyContainer, ...@@ -639,9 +639,6 @@ class ObjectManager(CopyContainer,
def _getImportPaths(self): def _getImportPaths(self):
cfg = getConfiguration() cfg = getConfiguration()
paths = [] 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: if not cfg.instancehome in paths:
paths.append(cfg.instancehome) paths.append(cfg.instancehome)
if not cfg.clienthome in paths: if not cfg.clienthome in paths:
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
ZTC makes the following assumptions about its environment: ZTC makes the following assumptions about its environment:
a) The 'ZopeTestCase' package is installed in the Zope "trunk" inside the 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 c) none
SOFTWARE_HOME or INSTANCE_HOME, typically in Products/MyCoolProduct/tests.
d) The somewhat weak assumption is that ZTC can walk up the directory tree from 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 'tests', and find a 'Products' directory. This is how INSTANCE_HOME
...@@ -23,9 +22,8 @@ The non-trivial part is that INSTANCE_HOME has two distinct purposes: ...@@ -23,9 +22,8 @@ The non-trivial part is that INSTANCE_HOME has two distinct purposes:
2) INSTANCE_HOME/custom_zodb.py must be used to set up a ZODB. 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 ZTC attempts to resolve this by detecting an INSTANCE_HOME but leaving
the actual environment variable untouched so 2) works by still pointing into the actual environment variable untouched
SOFTWARE_HOME/Testing.
As soon as I allow you to set INSTANCE_HOME yourself, I lose the ability to 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. distinguish whether you mean 1) or 2) or both.
......
...@@ -5,7 +5,6 @@ When the skeleton test is run by typing 'python testSkeleton.py', it ...@@ -5,7 +5,6 @@ When the skeleton test is run by typing 'python testSkeleton.py', it
1. includes file framework.py 1. includes file framework.py
1.1 locates and imports the Testing package by means of 1.1 locates and imports the Testing package by means of
- SOFTWARE_HOME environment variable
- auto-detection - auto-detection
1.2 locates and includes file ztc_common.py 1.2 locates and includes file ztc_common.py
......
...@@ -115,16 +115,11 @@ class zdaemonEnvironDict(UserDict): ...@@ -115,16 +115,11 @@ class zdaemonEnvironDict(UserDict):
return self.data return self.data
# Datatype for the root configuration object # Datatype for the root configuration object
# (adds the softwarehome and zopehome fields; default values for some # (default values for some computed paths, configures the dbtab)
# computed paths, configures the dbtab)
def root_config(section): def root_config(section):
from ZConfig import ConfigurationError from ZConfig import ConfigurationError
from ZConfig.matcher import SectionValue 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: if section.environment is None:
section.environment = zdaemonEnvironDict() section.environment = zdaemonEnvironDict()
if section.cgi_environment is None: if section.cgi_environment is None:
......
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