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
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.
......
......@@ -239,8 +239,6 @@ class DebugManager(Item, Implicit):
InitializeClass(DebugManager)
class ApplicationManager(Folder, CacheManager):
"""System management
"""
......@@ -350,41 +348,6 @@ class ApplicationManager(Folder, CacheManager):
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,22 +369,6 @@ class ApplicationManager(Folder, CacheManager):
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
......
......@@ -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 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
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 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
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 @@ def getObject(module, name, reload=0,
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
......@@ -18,22 +18,6 @@ import sys
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:
......
......@@ -47,7 +47,7 @@ class ImageFile(Explicit):
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(''):
......
......@@ -52,16 +52,6 @@ def setConfiguration(cfg):
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 @@ class DefaultConfiguration:
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
......
......@@ -45,7 +45,7 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
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'))
......
......@@ -414,50 +414,6 @@ class ApplicationManagerTests(ConfigTestBase,
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()
......
This diff is collapsed.
......@@ -26,15 +26,11 @@ class SetConfigTests(unittest.TestCase):
# 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 @@ class SetConfigTests(unittest.TestCase):
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)
......
......@@ -639,9 +639,6 @@ class ObjectManager(CopyContainer,
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:
......
......@@ -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 @@ 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.
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.
......
......@@ -5,7 +5,6 @@ When the skeleton test is run by typing 'python testSkeleton.py', it
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
......
......@@ -115,16 +115,11 @@ class zdaemonEnvironDict(UserDict):
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:
......
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