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 =
python-gettext
defaults = ['--module', '!^(zope[.]app)[.]']
environment = test-environment
......@@ -15,12 +15,6 @@ eggs =
[test]
recipe = zc.recipe.testrunner
eggs = ${buildout:eggs}
environment = test-environment
[test-environment]
SOFTWARE_HOME = ${buildout:directory}/src
ZOPE_HOME = ${buildout:directory}
INSTANCE_HOME = ${buildout:directory}
[scripts]
recipe = zc.recipe.egg:scripts
......
......@@ -23,6 +23,10 @@ Known issues
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
on does no longer exist.
......
......@@ -433,10 +433,12 @@ class ApplicationManager(Folder,CacheManager):
return info
def getSOFTWARE_HOME(self):
return getConfiguration().softwarehome
cfg = getConfiguration()
return getattr(cfg, 'softwarehome', None)
def getZOPE_HOME(self):
return getConfiguration().zopehome
cfg = getConfiguration()
return getattr(cfg, 'zopehome', None)
def getINSTANCE_HOME(self):
return getConfiguration().instancehome
......
......@@ -17,7 +17,7 @@ Extensions currently include external methods and pluggable brains.
$Id$'''
__version__='$Revision: 1.23 $'[11:-2]
import os, zlib, imp
import os, imp
import Products
from zExceptions import NotFound
path_split=os.path.split
......@@ -91,10 +91,17 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)):
if result is None:
import App.config
cfg = App.config.getConfiguration()
sw=os.path.dirname(os.path.dirname(cfg.softwarehome))
for home in (cfg.instancehome, sw):
locations = []
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)
if r is not None: result = r
if r is not None:
result = r
del locations
if result is None:
try:
......
......@@ -20,42 +20,30 @@ import os
import sys
import Products
from App.Common import package_home
try:
home = os.environ['SOFTWARE_HOME']
except KeyError:
import Zope2
home = os.path.abspath(package_home(Zope2.__dict__))
home, e = os.path.split(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
pass
else:
home = os.path.realpath(home)
__builtin__.SOFTWARE_HOME = SOFTWARE_HOME = home
try:
zhome = os.environ['ZOPE_HOME']
except KeyError:
zhome = os.path.join(home, '..', '..')
__builtin__.ZOPE_HOME = ZOPE_HOME = os.path.realpath(zhome)
pass
else:
zhome = os.path.realpath(zhome)
__builtin__.ZOPE_HOME = ZOPE_HOME = zhome
try:
chome = os.environ['INSTANCE_HOME']
except KeyError:
chome = home
d, e = os.path.split(chome)
if e == 'python':
d, e = os.path.split(d)
if e == 'lib':
chome = d or os.getcwd()
import Zope2
base = os.path.dirname(Zope2.__file__)
base = os.path.join(base, os.path.pardir, os.path.pardir)
chome = os.path.realpath(base)
else:
chome = os.path.realpath(chome)
inst_ppath = os.path.join(chome, 'lib', 'python')
......
......@@ -15,6 +15,7 @@
__version__='$Revision: 1.20 $'[11:-2]
import os
import os.path
import stat
import time
......@@ -28,15 +29,21 @@ from DateTime.DateTime import DateTime
from zope.contenttype import guess_content_type
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):
"""Image objects stored in external files."""
security = ClassSecurityInfo()
def __init__(self,path,_prefix=None):
def __init__(self, path, _prefix=None):
import Globals # for data
if _prefix is None:
_prefix=getConfiguration().softwarehome
_prefix=getattr(getConfiguration(), 'softwarehome', PREFIX)
elif type(_prefix) is not type(''):
_prefix=package_home(_prefix)
path = os.path.join(_prefix, path)
......
......@@ -48,26 +48,28 @@ def setConfiguration(cfg):
from App import FindHomes
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
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
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.data_dir = cfg.clienthome
__builtin__.INSTANCE_HOME = FindHomes.INSTANCE_HOME = cfg.instancehome
os.environ["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
class DefaultConfiguration:
......@@ -78,8 +80,10 @@ class DefaultConfiguration:
from App import FindHomes
self.clienthome = FindHomes.CLIENT_HOME
self.instancehome = FindHomes.INSTANCE_HOME
self.softwarehome = FindHomes.SOFTWARE_HOME
self.zopehome = FindHomes.ZOPE_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 = True
......
......@@ -19,6 +19,12 @@ from App.config import getConfiguration
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,):
"Persistent HTML Document Templates"
......@@ -32,14 +38,16 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
_need__name__=1
_v_last_read=0
def __init__(self,name,_prefix=None, **kw):
if _prefix is None: _prefix=getConfiguration().softwarehome
def __init__(self, name, _prefix=None, **kw):
if _prefix is None:
_prefix = getattr(getConfiguration(), 'softwarehome', PREFIX)
import pdb; pdb.set_trace()
elif type(_prefix) is not type(''):
_prefix=Common.package_home(_prefix)
_prefix = Common.package_home(_prefix)
args=(self, os.path.join(_prefix, name + '.dtml'))
if not kw.has_key('__name__'):
kw['__name__']=os.path.split(name)[-1]
apply(ClassicHTMLFile.inheritedAttribute('__init__'),args,kw)
kw['__name__'] = os.path.split(name)[-1]
apply(ClassicHTMLFile.inheritedAttribute('__init__'), args, kw)
def _cook_check(self):
if Globals.DevelopmentMode:
......
......@@ -659,7 +659,10 @@ class ObjectManager(CopyContainer,
def list_imports(self):
listing = []
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:
paths.append(cfg.instancehome)
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