[Checkins] SVN: Zope/trunk/ 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.

Hanno Schlichting plone at hannosch.info
Fri Feb 20 09:31:51 EST 2009


Log message for revision 96818:
  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.
  

Changed:
  U   Zope/trunk/alltests.cfg
  U   Zope/trunk/buildout.cfg
  U   Zope/trunk/doc/CHANGES.txt
  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/OFS/ObjectManager.py

-=-
Modified: Zope/trunk/alltests.cfg
===================================================================
--- Zope/trunk/alltests.cfg	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/alltests.cfg	2009-02-20 14:31:50 UTC (rev 96818)
@@ -73,4 +73,3 @@
     python-gettext
 
 defaults = ['--module', '!^(zope[.]app)[.]']
-environment = test-environment

Modified: Zope/trunk/buildout.cfg
===================================================================
--- Zope/trunk/buildout.cfg	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/buildout.cfg	2009-02-20 14:31:50 UTC (rev 96818)
@@ -15,13 +15,7 @@
 [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
 eggs = Zope2

Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/doc/CHANGES.txt	2009-02-20 14:31:50 UTC (rev 96818)
@@ -23,6 +23,10 @@
 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.
 

Modified: Zope/trunk/src/App/ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/ApplicationManager.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/ApplicationManager.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -433,10 +433,12 @@
         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

Modified: Zope/trunk/src/App/Extensions.py
===================================================================
--- Zope/trunk/src/App/Extensions.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/Extensions.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -17,7 +17,7 @@
 $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 @@
     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:

Modified: Zope/trunk/src/App/FindHomes.py
===================================================================
--- Zope/trunk/src/App/FindHomes.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/FindHomes.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -20,42 +20,30 @@
 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__))
+    pass
+else:
+    home = os.path.realpath(home)
+    __builtin__.SOFTWARE_HOME = SOFTWARE_HOME = home
 
-    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
-
 try:
     zhome = os.environ['ZOPE_HOME']
 except KeyError:
-    zhome = os.path.join(home, '..', '..')
+    pass
+else:
+    zhome = os.path.realpath(zhome)
+    __builtin__.ZOPE_HOME = ZOPE_HOME = zhome
 
-__builtin__.ZOPE_HOME = ZOPE_HOME = os.path.realpath(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')

Modified: Zope/trunk/src/App/ImageFile.py
===================================================================
--- Zope/trunk/src/App/ImageFile.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/ImageFile.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -15,6 +15,7 @@
 __version__='$Revision: 1.20 $'[11:-2]
 
 import os
+import os.path
 import stat
 import time
 
@@ -28,15 +29,21 @@
 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)

Modified: Zope/trunk/src/App/config.py
===================================================================
--- Zope/trunk/src/App/config.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/config.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -48,26 +48,28 @@
 
     from App import FindHomes
     import __builtin__
+    import os
+    import Globals  # to set data
+
     __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
-    __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
+    Globals.INSTANCE_HOME = cfg.instancehome
 
-    import Globals  # to set data
-    Globals.data_dir = cfg.clienthome
-    # Globals does not export CLIENT_HOME
-    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 @@
         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

Modified: Zope/trunk/src/App/special_dtml.py
===================================================================
--- Zope/trunk/src/App/special_dtml.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/App/special_dtml.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -19,6 +19,12 @@
 
 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 @@
     _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:

Modified: Zope/trunk/src/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/ObjectManager.py	2009-02-20 14:29:57 UTC (rev 96817)
+++ Zope/trunk/src/OFS/ObjectManager.py	2009-02-20 14:31:50 UTC (rev 96818)
@@ -659,7 +659,10 @@
     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:



More information about the Checkins mailing list