Commit 50447696 authored by Hanno Schlichting's avatar Hanno Schlichting

Remove `Globals` package.

Opened database are now found in `Zope2.opened` next to `Zope2.DB`.
Also stop setting client/instance home variables onto `__builtin__`,
those are available from `App.config.getConfiguration()` as
`instancehome` and `clienthome` attributes.
parent 58f96d0a
...@@ -28,6 +28,9 @@ Features Added ...@@ -28,6 +28,9 @@ Features Added
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Remove `Globals` package, opened database are now found in
`Zope2.opened` next to `Zope2.DB`.
- Remove proxy role support from DTML documents and methods. - Remove proxy role support from DTML documents and methods.
- Remove ZCacheable logic and StandardCacheManagers dependency. - Remove ZCacheable logic and StandardCacheManagers dependency.
......
...@@ -10,13 +10,8 @@ ...@@ -10,13 +10,8 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Stick directory information in the built-in namespace."""
import __builtin__
import os import os
import sys
import Products
try: try:
chome = os.environ['INSTANCE_HOME'] chome = os.environ['INSTANCE_HOME']
...@@ -27,47 +22,10 @@ except KeyError: ...@@ -27,47 +22,10 @@ except KeyError:
chome = os.path.realpath(base) chome = os.path.realpath(base)
else: else:
chome = os.path.realpath(chome) chome = os.path.realpath(chome)
inst_ppath = os.path.join(chome, 'lib', 'python')
if os.path.isdir(inst_ppath):
sys.path.insert(0, inst_ppath)
__builtin__.INSTANCE_HOME = INSTANCE_HOME = chome INSTANCE_HOME = chome
# CLIENT_HOME allows ZEO clients to easily keep distinct pid and
# log files. This is currently an *experimental* feature, as I expect
# that increasing ZEO deployment will cause bigger changes to the
# way that z2.py works fairly soon.
try: try:
CLIENT_HOME = os.environ['CLIENT_HOME'] CLIENT_HOME = os.environ['CLIENT_HOME']
except KeyError: except KeyError:
CLIENT_HOME = os.path.join(INSTANCE_HOME, 'var') CLIENT_HOME = os.path.join(INSTANCE_HOME, 'var')
__builtin__.CLIENT_HOME = CLIENT_HOME
# If there is a Products package in INSTANCE_HOME, add it to the
# Products package path
ip = os.path.join(INSTANCE_HOME, 'Products')
ippart = 0
ppath = Products.__path__
if os.path.isdir(ip) and ip not in ppath:
disallow = os.environ.get('DISALLOW_LOCAL_PRODUCTS', '').lower()
if disallow in ('no', 'off', '0', ''):
ppath.insert(0, ip)
ippart = 1
ppathpat = os.environ.get('PRODUCTS_PATH', None)
if ppathpat is not None:
psep = os.pathsep
if ppathpat.find('%(') >= 0:
newppath = (ppathpat % {
'PRODUCTS_PATH': psep.join(ppath),
'SOFTWARE_PRODUCTS': psep.join(ppath[ippart:]),
'INSTANCE_PRODUCTS': ip,
}).split(psep)
else:
newppath = ppathpat.split(psep)
del ppath[:]
for p in filter(None, newppath):
p = os.path.abspath(p)
if os.path.isdir(p) and p not in ppath:
ppath.append(p)
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
# #
############################################################################## ##############################################################################
import os
_config = None _config = None
...@@ -41,20 +43,11 @@ def setConfiguration(cfg): ...@@ -41,20 +43,11 @@ def setConfiguration(cfg):
return return
from App import FindHomes from App import FindHomes
import __builtin__ FindHomes.CLIENT_HOME = cfg.clienthome
import os
import Globals # to set data
__builtin__.CLIENT_HOME = FindHomes.CLIENT_HOME = cfg.clienthome
os.environ["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 FindHomes.INSTANCE_HOME = cfg.instancehome
os.environ["INSTANCE_HOME"] = cfg.instancehome os.environ["INSTANCE_HOME"] = cfg.instancehome
Globals.INSTANCE_HOME = cfg.instancehome
Globals.DevelopmentMode = cfg.debug_mode
class DefaultConfiguration: class DefaultConfiguration:
......
...@@ -47,29 +47,12 @@ class SetConfigTests(unittest.TestCase): ...@@ -47,29 +47,12 @@ class SetConfigTests(unittest.TestCase):
def testClientHomeLegacySources(self): def testClientHomeLegacySources(self):
import os import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(clienthome='foo') self.setconfig(clienthome='foo')
self.assertEqual(self.getconfig('clienthome'), 'foo')
self.assertEqual(os.environ.get('CLIENT_HOME'), 'foo') self.assertEqual(os.environ.get('CLIENT_HOME'), 'foo')
self.assertEqual(App.FindHomes.CLIENT_HOME, 'foo')
self.assertEqual(__builtin__.CLIENT_HOME, 'foo')
self.assertEqual(Globals.data_dir, 'foo')
def testInstanceHomeLegacySources(self): def testInstanceHomeLegacySources(self):
import os import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(instancehome='foo') self.setconfig(instancehome='foo')
self.assertEqual(self.getconfig('instancehome'), 'foo')
self.assertEqual(os.environ.get('INSTANCE_HOME'), 'foo') self.assertEqual(os.environ.get('INSTANCE_HOME'), 'foo')
self.assertEqual(App.FindHomes.INSTANCE_HOME, 'foo')
self.assertEqual(__builtin__.INSTANCE_HOME, 'foo')
self.assertEqual(Globals.INSTANCE_HOME, 'foo')
def testDebugModeLegacySources(self):
import Globals # for data
self.setconfig(debug_mode=True)
self.assertEqual(Globals.DevelopmentMode, True)
self.setconfig(debug_mode=False)
self.assertEqual(Globals.DevelopmentMode, False)
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Shared global data
o N.B.: DO NOT IMPORT ANYTHING HERE! This module is just for shared data!
"""
DevelopmentMode = False
# ZODB stashes the main database object here
opened = []
...@@ -71,7 +71,6 @@ def patch_persistent(): ...@@ -71,7 +71,6 @@ def patch_persistent():
def startup(): def startup():
import Globals # to set / fetch data
patch_persistent() patch_persistent()
global app global app
...@@ -120,9 +119,8 @@ def startup(): ...@@ -120,9 +119,8 @@ def startup():
notify(DatabaseOpened(DB)) notify(DatabaseOpened(DB))
Globals.DB = DB
Zope2.DB = DB Zope2.DB = DB
Globals.opened.append(DB) Zope2.opened.append(DB)
import ClassFactory import ClassFactory
DB.classFactory = ClassFactory.ClassFactory DB.classFactory = ClassFactory.ClassFactory
......
...@@ -66,6 +66,7 @@ def _configure_wsgi(): ...@@ -66,6 +66,7 @@ def _configure_wsgi():
# Zope2.App.startup.startup() sets the following variables in this module. # Zope2.App.startup.startup() sets the following variables in this module.
DB = None DB = None
opened = []
bobo_application = None bobo_application = None
zpublisher_transactions_manager = None zpublisher_transactions_manager = None
zpublisher_validated_hook = None zpublisher_validated_hook = 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