[Zope-Coders] ZOPE_HOME

Matt Behrens matt@zigg.com
Thu, 4 Jul 2002 09:53:44 -0400


In addition to merging the installer branch's setup.py as previously
discussed and agreed on, I'd also like to merge ZOPE_HOME support
into 2.6.  I do not see any way this could break anyone's current
ways of doing things.

This is another variable previously proposed by Evan (IIRC) but
never implemented.  It points to the directory where ZServer, z2.py,
et al. are installed to.  It is needed to find the import directory
now that Examples are imported automatically.

This is useful for my setup.py because it must currently pull modules
out of both the root of the Zope tarball as well as lib/python, and
a single distutils run can only install into one target directory
(if someone knows otherwise, please let me know.)  Being able to
set ZOPE_HOME means the software's import directory can still be
accessed.

If ZOPE_HOME doesn't go in, there must be two setup.py's -- one for
ZServer, z2.py et al, and one for everything in lib/python.

Index: App/ApplicationManager.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/App/ApplicationManager.py,v
retrieving revision 1.78
retrieving revision 1.78.52.1
diff -u -r1.78 -r1.78.52.1
--- App/ApplicationManager.py	7 Feb 2002 17:37:10 -0000	1.78
+++ App/ApplicationManager.py	27 May 2002 22:58:03 -0000	1.78.52.1
@@ -412,6 +412,9 @@
             
     def getSOFTWARE_HOME(self):
         return SOFTWARE_HOME
+
+    def getZOPE_HOME(self):
+        return ZOPE_HOME
 
     def getINSTANCE_HOME(self):
         return INSTANCE_HOME
Index: App/FindHomes.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/App/FindHomes.py,v
retrieving revision 1.9
retrieving revision 1.9.20.1
diff -u -r1.9 -r1.9.20.1
--- App/FindHomes.py	20 Mar 2002 22:03:17 -0000	1.9
+++ App/FindHomes.py	27 May 2002 22:58:03 -0000	1.9.20.1
@@ -33,6 +33,13 @@
 
 home=realpath(home)
 sys.modules['__builtin__'].SOFTWARE_HOME=SOFTWARE_HOME=home
+
+try: zhome=os.environ['ZOPE_HOME']
+except:
+    zhome=os.path.join(home, '..', '..')
+
+zhome=realpath(zhome)
+sys.modules['__builtin__'].ZOPE_HOME=ZOPE_HOME=zhome
 
 try:
     chome=os.environ['INSTANCE_HOME']
Index: App/dtml/cpContents.dtml
===================================================================
RCS file: /cvs-repository/Zope/lib/python/App/dtml/cpContents.dtml,v
retrieving revision 1.3
retrieving revision 1.3.112.1
diff -u -r1.3 -r1.3.112.1
--- App/dtml/cpContents.dtml	20 Sep 2001 01:43:03 -0000	1.3
+++ App/dtml/cpContents.dtml	27 May 2002 22:58:03 -0000	1.3.112.1
@@ -59,6 +59,18 @@
 <tr>
   <td align="left" valign="top">
   <div class="form-label">
+  ZOPE_HOME
+  </div>
+  </td>
+  <td align="left" valign="top">
+  <div class="form-text">
+  <dtml-var getZOPE_HOME>
+  </div>
+  </td>
+</tr>
+<tr>
+  <td align="left" valign="top">
+  <div class="form-label">
   INSTANCE_HOME
   </div>
   </td>
Index: OFS/Application.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/OFS/Application.py,v
retrieving revision 1.183
retrieving revision 1.183.10.1
diff -u -r1.183 -r1.183.10.1
--- OFS/Application.py	12 Apr 2002 16:06:01 -0000	1.183
+++ OFS/Application.py	27 May 2002 22:58:03 -0000	1.183.10.1
@@ -375,8 +375,8 @@
     if not hasattr(app, 'Examples') and not \
        hasattr(app, '_Zope25_examples_have_been_added'):
 
-        examples_path = os.path.join(Globals.SOFTWARE_HOME, \
-             '..','..','import', 'Examples.zexp')
+        examples_path = os.path.join(Globals.ZOPE_HOME, \
+             'import', 'Examples.zexp')
 
         if os.path.isfile(examples_path):
             app._importObjectFromFile(examples_path, verify=0)
Index: OFS/ObjectManager.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/OFS/ObjectManager.py,v
retrieving revision 1.150
retrieving revision 1.150.10.1
diff -u -r1.150 -r1.150.10.1
--- OFS/ObjectManager.py	15 Apr 2002 10:15:26 -0000	1.150
+++ OFS/ObjectManager.py	27 May 2002 22:58:03 -0000	1.150.10.1
@@ -542,10 +542,9 @@
             raise BadRequestException, 'Invalid file name %s' % file
 
         instance_home = INSTANCE_HOME
-        software_home = os.path.join(SOFTWARE_HOME, '..%s..' % os.sep)
-        software_home = os.path.normpath(software_home)
+        zope_home = ZOPE_HOME
         
-        for impath in (instance_home, software_home):
+        for impath in (instance_home, zope_home):
             filepath = os.path.join(impath, 'import', file)
             if os.path.exists(filepath):
                 break