Commit 6f407460 authored by Hanno Schlichting's avatar Hanno Schlichting

Made the specification of `SOFTWARE_HOME` and `ZOPE_HOME` optional. In...

Made the specification of `SOFTWARE_HOME` and `ZOPE_HOME` optional. In addition `INSTANCE_HOME` is no longer required to run the tests of a source checkout of Zope.
parent e312bb44
...@@ -73,4 +73,3 @@ eggs = ...@@ -73,4 +73,3 @@ eggs =
python-gettext python-gettext
defaults = ['--module', '!^(zope[.]app)[.]'] defaults = ['--module', '!^(zope[.]app)[.]']
environment = test-environment
...@@ -15,12 +15,6 @@ eggs = ...@@ -15,12 +15,6 @@ eggs =
[test] [test]
recipe = zc.recipe.testrunner recipe = zc.recipe.testrunner
eggs = ${buildout:eggs} eggs = ${buildout:eggs}
environment = test-environment
[test-environment]
SOFTWARE_HOME = ${buildout:directory}/src
ZOPE_HOME = ${buildout:directory}
INSTANCE_HOME = ${buildout:directory}
[scripts] [scripts]
recipe = zc.recipe.egg:scripts recipe = zc.recipe.egg:scripts
......
...@@ -23,6 +23,10 @@ Known issues ...@@ -23,6 +23,10 @@ Known issues
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Made the specification of `SOFTWARE_HOME` and `ZOPE_HOME` optional. In
addition `INSTANCE_HOME` is no longer required to run the tests of a
source checkout of Zope.
- Removed the `test` command from zopectl. The test.py script it was relying - Removed the `test` command from zopectl. The test.py script it was relying
on does no longer exist. on does no longer exist.
......
...@@ -433,10 +433,12 @@ class ApplicationManager(Folder,CacheManager): ...@@ -433,10 +433,12 @@ class ApplicationManager(Folder,CacheManager):
return info return info
def getSOFTWARE_HOME(self): def getSOFTWARE_HOME(self):
return getConfiguration().softwarehome cfg = getConfiguration()
return getattr(cfg, 'softwarehome', None)
def getZOPE_HOME(self): def getZOPE_HOME(self):
return getConfiguration().zopehome cfg = getConfiguration()
return getattr(cfg, 'zopehome', None)
def getINSTANCE_HOME(self): def getINSTANCE_HOME(self):
return getConfiguration().instancehome return getConfiguration().instancehome
......
...@@ -17,7 +17,7 @@ Extensions currently include external methods and pluggable brains. ...@@ -17,7 +17,7 @@ Extensions currently include external methods and pluggable brains.
$Id$''' $Id$'''
__version__='$Revision: 1.23 $'[11:-2] __version__='$Revision: 1.23 $'[11:-2]
import os, zlib, imp import os, imp
import Products import Products
from zExceptions import NotFound from zExceptions import NotFound
path_split=os.path.split path_split=os.path.split
...@@ -91,10 +91,17 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)): ...@@ -91,10 +91,17 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)):
if result is None: if result is None:
import App.config import App.config
cfg = App.config.getConfiguration() cfg = App.config.getConfiguration()
sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) locations = []
for home in (cfg.instancehome, sw): locations.append(cfg.instancehome)
sw = getattr(cfg, 'softwarehome', None)
if sw is not None:
sw = os.path.dirname(sw)
locations.append(sw)
for home in locations:
r=_getPath(home, prefix, name, suffixes) r=_getPath(home, prefix, name, suffixes)
if r is not None: result = r if r is not None:
result = r
del locations
if result is None: if result is None:
try: try:
......
...@@ -20,42 +20,30 @@ import os ...@@ -20,42 +20,30 @@ import os
import sys import sys
import Products import Products
from App.Common import package_home
try: try:
home = os.environ['SOFTWARE_HOME'] home = os.environ['SOFTWARE_HOME']
except KeyError: except KeyError:
import Zope2 pass
home = os.path.abspath(package_home(Zope2.__dict__)) else:
home = os.path.realpath(home)
home, e = os.path.split(home) __builtin__.SOFTWARE_HOME = SOFTWARE_HOME = home
d, e = os.path.split(home)
if e == '.':
home = d
d, e = os.path.split(home)
if e == '..':
home = os.path.dirname(d)
home = os.path.realpath(home)
__builtin__.SOFTWARE_HOME = SOFTWARE_HOME = home
try: try:
zhome = os.environ['ZOPE_HOME'] zhome = os.environ['ZOPE_HOME']
except KeyError: except KeyError:
zhome = os.path.join(home, '..', '..') pass
else:
__builtin__.ZOPE_HOME = ZOPE_HOME = os.path.realpath(zhome) 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:
chome = home import Zope2
d, e = os.path.split(chome) base = os.path.dirname(Zope2.__file__)
if e == 'python': base = os.path.join(base, os.path.pardir, os.path.pardir)
d, e = os.path.split(d) chome = os.path.realpath(base)
if e == 'lib':
chome = d or os.getcwd()
else: else:
chome = os.path.realpath(chome) chome = os.path.realpath(chome)
inst_ppath = os.path.join(chome, 'lib', 'python') inst_ppath = os.path.join(chome, 'lib', 'python')
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
__version__='$Revision: 1.20 $'[11:-2] __version__='$Revision: 1.20 $'[11:-2]
import os import os
import os.path
import stat import stat
import time import time
...@@ -28,15 +29,21 @@ from DateTime.DateTime import DateTime ...@@ -28,15 +29,21 @@ from DateTime.DateTime import DateTime
from zope.contenttype import guess_content_type from zope.contenttype import guess_content_type
from ZPublisher.Iterators import filestream_iterator from ZPublisher.Iterators import filestream_iterator
import Zope2
PREFIX = os.path.realpath(
os.path.join(os.path.dirname(Zope2.__file__), os.path.pardir)
)
class ImageFile(Explicit): class ImageFile(Explicit):
"""Image objects stored in external files.""" """Image objects stored in external files."""
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self,path,_prefix=None): def __init__(self, path, _prefix=None):
import Globals # for data import Globals # for data
if _prefix is None: if _prefix is None:
_prefix=getConfiguration().softwarehome _prefix=getattr(getConfiguration(), 'softwarehome', PREFIX)
elif type(_prefix) is not type(''): elif type(_prefix) is not type(''):
_prefix=package_home(_prefix) _prefix=package_home(_prefix)
path = os.path.join(_prefix, path) path = os.path.join(_prefix, path)
......
...@@ -48,26 +48,28 @@ def setConfiguration(cfg): ...@@ -48,26 +48,28 @@ def setConfiguration(cfg):
from App import FindHomes from App import FindHomes
import __builtin__ import __builtin__
__builtin__.CLIENT_HOME = FindHomes.CLIENT_HOME = cfg.clienthome
__builtin__.INSTANCE_HOME = FindHomes.INSTANCE_HOME = cfg.instancehome
__builtin__.SOFTWARE_HOME = FindHomes.SOFTWARE_HOME = cfg.softwarehome
__builtin__.ZOPE_HOME = FindHomes.ZOPE_HOME = cfg.zopehome
# XXX make sure the environment variables, if set, don't get out
# of sync. This is needed to support 3rd-party code written to
# support Zope versions prior to 2.7.
import os import os
os.environ["CLIENT_HOME"] = cfg.clienthome
os.environ["INSTANCE_HOME"] = cfg.instancehome
os.environ["SOFTWARE_HOME"] = cfg.softwarehome
os.environ["ZOPE_HOME"] = cfg.zopehome
import Globals # to set data import Globals # to set data
Globals.data_dir = cfg.clienthome
__builtin__.CLIENT_HOME = FindHomes.CLIENT_HOME = cfg.clienthome
os.environ["CLIENT_HOME"] = cfg.clienthome
# Globals does not export CLIENT_HOME # Globals does not export CLIENT_HOME
Globals.data_dir = cfg.clienthome
__builtin__.INSTANCE_HOME = FindHomes.INSTANCE_HOME = cfg.instancehome
os.environ["INSTANCE_HOME"] = cfg.instancehome
Globals.INSTANCE_HOME = cfg.instancehome Globals.INSTANCE_HOME = cfg.instancehome
Globals.SOFTWARE_HOME = cfg.softwarehome
Globals.ZOPE_HOME = cfg.zopehome 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:
...@@ -78,8 +80,10 @@ class DefaultConfiguration: ...@@ -78,8 +80,10 @@ 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
self.softwarehome = FindHomes.SOFTWARE_HOME if hasattr(FindHomes, 'SOFTWARE_HOME'):
self.zopehome = FindHomes.ZOPE_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 = True self.enable_product_installation = True
......
...@@ -19,6 +19,12 @@ from App.config import getConfiguration ...@@ -19,6 +19,12 @@ from App.config import getConfiguration
LOG = getLogger('special_dtml') LOG = getLogger('special_dtml')
import Zope2
PREFIX = os.path.realpath(
os.path.join(os.path.dirname(Zope2.__file__), os.path.pardir)
)
class HTML(DocumentTemplate.HTML,Persistence.Persistent,): class HTML(DocumentTemplate.HTML,Persistence.Persistent,):
"Persistent HTML Document Templates" "Persistent HTML Document Templates"
...@@ -32,14 +38,16 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,): ...@@ -32,14 +38,16 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
_need__name__=1 _need__name__=1
_v_last_read=0 _v_last_read=0
def __init__(self,name,_prefix=None, **kw): def __init__(self, name, _prefix=None, **kw):
if _prefix is None: _prefix=getConfiguration().softwarehome if _prefix is None:
_prefix = getattr(getConfiguration(), 'softwarehome', PREFIX)
import pdb; pdb.set_trace()
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'))
if not kw.has_key('__name__'): if not kw.has_key('__name__'):
kw['__name__']=os.path.split(name)[-1] kw['__name__'] = os.path.split(name)[-1]
apply(ClassicHTMLFile.inheritedAttribute('__init__'),args,kw) apply(ClassicHTMLFile.inheritedAttribute('__init__'), args, kw)
def _cook_check(self): def _cook_check(self):
if Globals.DevelopmentMode: if Globals.DevelopmentMode:
......
...@@ -659,7 +659,10 @@ class ObjectManager(CopyContainer, ...@@ -659,7 +659,10 @@ class ObjectManager(CopyContainer,
def list_imports(self): def list_imports(self):
listing = [] listing = []
cfg = getConfiguration() cfg = getConfiguration()
paths = [cfg.zopehome] paths = []
zopehome = getattr(cfg, 'zopehome', None)
if zopehome is not None and cfg.zopehome is not None:
paths.append(zopegome)
if not cfg.instancehome in paths: if not cfg.instancehome in paths:
paths.append(cfg.instancehome) paths.append(cfg.instancehome)
for impath in paths: for impath in paths:
......
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