Commit 71b0533c authored by Jim Fulton's avatar Jim Fulton

Adjusted the modules in the Zope 2 package to import from Zope2.

Added a Zope facade module that redirects to Zope 2.  Tests pass.
Zope starts. :)
parent 3e4b2797
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Legacy Zope "package" that redirects to the new Zope 2 package
$Id$
"""
import sys, Zope2
sys.modules['Zope'] = Zope2
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Initialize the Zope Package and provide a published module """Initialize the Zope2 Package and provide a published module
""" """
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
...@@ -33,7 +33,7 @@ import os ...@@ -33,7 +33,7 @@ import os
import sys import sys
import ZODB import ZODB
import ZODB.ZApplication import ZODB.ZApplication
import Zope import Zope2
import ZPublisher import ZPublisher
...@@ -58,7 +58,7 @@ def startup(): ...@@ -58,7 +58,7 @@ def startup():
DB = configuration.dbtab.getDatabase('/', is_root=1) DB = configuration.dbtab.getDatabase('/', is_root=1)
Globals.BobobaseName = DB.getName() Globals.BobobaseName = DB.getName()
else: else:
m=imp.load_module('Zope.custom_zodb', m[0], m[1], m[2]) m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2])
if hasattr(m,'DB'): if hasattr(m,'DB'):
DB=m.DB DB=m.DB
else: else:
...@@ -66,14 +66,14 @@ def startup(): ...@@ -66,14 +66,14 @@ def startup():
DB = ZODB.DB(storage) DB = ZODB.DB(storage)
Globals.BobobaseName = DB.getName() Globals.BobobaseName = DB.getName()
sys.modules['Zope.custom_zodb']=m sys.modules['Zope2.custom_zodb']=m
if DB.getActivityMonitor() is None: if DB.getActivityMonitor() is None:
from ZODB.ActivityMonitor import ActivityMonitor from ZODB.ActivityMonitor import ActivityMonitor
DB.setActivityMonitor(ActivityMonitor()) DB.setActivityMonitor(ActivityMonitor())
Globals.DB = DB # Ick, this is temporary until we come up with some registry Globals.DB = DB # Ick, this is temporary until we come up with some registry
Zope.DB = DB Zope2.DB = DB
# Hook for providing multiple transaction object manager undo support: # Hook for providing multiple transaction object manager undo support:
Globals.UndoManager=DB Globals.UndoManager=DB
...@@ -90,7 +90,7 @@ def startup(): ...@@ -90,7 +90,7 @@ def startup():
app = ZODB.ZApplication.ZApplicationWrapper( app = ZODB.ZApplication.ZApplicationWrapper(
DB, 'Application', OFS.Application.Application, (), DB, 'Application', OFS.Application.Application, (),
Globals.VersionNameName) Globals.VersionNameName)
Zope.bobo_application = app Zope2.bobo_application = app
# Initialize the app object # Initialize the app object
application = app() application = app()
...@@ -104,17 +104,13 @@ def startup(): ...@@ -104,17 +104,13 @@ def startup():
# "Log off" as system user # "Log off" as system user
noSecurityManager() noSecurityManager()
# This is really ugly. Please remember to remove Main.py before
# Zope 2.7 and fix whatever breaks, if anything.
sys.modules['Main'] = sys.modules['Zope']
global startup_time global startup_time
startup_time = log_time() startup_time = log_time()
Zope.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_transactions_manager = TransactionsManager()
Zope.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_exception_hook = zpublisher_exception_hook
Zope.zpublisher_validated_hook = validated_hook Zope2.zpublisher_validated_hook = validated_hook
Zope.__bobo_before__ = noSecurityManager Zope2.__bobo_before__ = noSecurityManager
def validated_hook(request, user): def validated_hook(request, user):
...@@ -129,7 +125,7 @@ def validated_hook(request, user): ...@@ -129,7 +125,7 @@ def validated_hook(request, user):
expires="Mon, 25-Jan-1999 23:59:59 GMT", expires="Mon, 25-Jan-1999 23:59:59 GMT",
path=(request['BASEPATH1'] or '/'), path=(request['BASEPATH1'] or '/'),
) )
Zope.DB.removeVersionPool(version) Zope2.DB.removeVersionPool(version)
raise Unauthorized, "You don't have permission to enter versions." raise Unauthorized, "You don't have permission to enter versions."
......
...@@ -252,8 +252,8 @@ class ZopeStarter: ...@@ -252,8 +252,8 @@ class ZopeStarter:
def startZope(self): def startZope(self):
# Import Zope # Import Zope
import Zope import Zope2
Zope.startup() Zope2.startup()
def makeLockFile(self): def makeLockFile(self):
if not self.cfg.zserver_read_only_mode: if not self.cfg.zserver_read_only_mode:
...@@ -268,7 +268,7 @@ class ZopeStarter: ...@@ -268,7 +268,7 @@ class ZopeStarter:
# if we can't lock it. # if we can't lock it.
# we need a separate lock file because on win32, locks are not # we need a separate lock file because on win32, locks are not
# advisory, otherwise we would just use the pid file # advisory, otherwise we would just use the pid file
from Zope.Startup.misc.lock_file import lock_file from Zope2.Startup.misc.lock_file import lock_file
lock_filename = self.cfg.lock_filename lock_filename = self.cfg.lock_filename
try: try:
if os.path.exists(lock_filename): if os.path.exists(lock_filename):
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
def run(): def run():
""" Start a Zope instance """ """ Start a Zope instance """
import Zope.Startup import Zope2.Startup
starter = Zope.Startup.get_starter() starter = Zope2.Startup.get_starter()
opts = _setconfig() opts = _setconfig()
starter.setConfiguration(opts.configroot) starter.setConfiguration(opts.configroot)
starter.prepare() starter.prepare()
...@@ -23,11 +23,11 @@ def run(): ...@@ -23,11 +23,11 @@ def run():
def configure(configfile): def configure(configfile):
""" Provide an API which allows scripts like zopectl to configure """ Provide an API which allows scripts like zopectl to configure
Zope before attempting to do 'app = Zope.app(). Should be used as Zope before attempting to do 'app = Zope2.app(). Should be used as
follows: from Zope.Startup.run import configure; follows: from Zope2.Startup.run import configure;
configure('/path/to/configfile'); import Zope; app = Zope.app() """ configure('/path/to/configfile'); import Zope2; app = Zope2.app() """
import Zope.Startup import Zope2.Startup
starter = Zope.Startup.get_starter() starter = Zope2.Startup.get_starter()
opts = _setconfig(configfile) opts = _setconfig(configfile)
starter.setConfiguration(opts.configroot) starter.setConfiguration(opts.configroot)
starter.setupSecurityOptions() starter.setupSecurityOptions()
...@@ -38,7 +38,7 @@ def _setconfig(configfile=None): ...@@ -38,7 +38,7 @@ def _setconfig(configfile=None):
""" Configure a Zope instance based on ZopeOptions. Optionally """ Configure a Zope instance based on ZopeOptions. Optionally
accept a configfile argument (string path) in order to specify accept a configfile argument (string path) in order to specify
where the configuration file exists. """ where the configuration file exists. """
from Zope.Startup import options, handlers from Zope2.Startup import options, handlers
from App import config from App import config
opts = options.ZopeOptions() opts = options.ZopeOptions()
if configfile: if configfile:
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
# #
############################################################################## ##############################################################################
"""Tests of the Zope.Startup package.""" """Tests of the Zope2.Startup package."""
...@@ -25,7 +25,7 @@ import ZConfig ...@@ -25,7 +25,7 @@ import ZConfig
from ZConfig.components.logger.tests import test_logger from ZConfig.components.logger.tests import test_logger
from ZConfig.components.logger.loghandler import NullHandler from ZConfig.components.logger.loghandler import NullHandler
import Zope.Startup import Zope2.Startup
from App.config import getConfiguration, setConfiguration from App.config import getConfiguration, setConfiguration
...@@ -33,7 +33,7 @@ TEMPNAME = tempfile.mktemp() ...@@ -33,7 +33,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products") TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
def getSchema(): def getSchema():
startup = os.path.dirname(Zope.Startup.__file__) startup = os.path.dirname(Zope2.Startup.__file__)
schemafile = os.path.join(startup, 'zopeschema.xml') schemafile = os.path.join(startup, 'zopeschema.xml')
return ZConfig.loadSchema(schemafile) return ZConfig.loadSchema(schemafile)
...@@ -70,7 +70,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -70,7 +70,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
logger.__dict__.update(logger_states[name]) logger.__dict__.update(logger_states[name])
def get_starter(self, conf): def get_starter(self, conf):
starter = Zope.Startup.get_starter() starter = Zope2.Startup.get_starter()
starter.setConfiguration(conf) starter.setConfiguration(conf)
return starter return starter
......
...@@ -20,9 +20,9 @@ import tempfile ...@@ -20,9 +20,9 @@ import tempfile
import unittest import unittest
import ZConfig import ZConfig
import Zope.Startup import Zope2.Startup
from Zope.Startup import datatypes from Zope2.Startup import datatypes
from App.config import getConfiguration from App.config import getConfiguration
...@@ -31,7 +31,7 @@ TEMPNAME = tempfile.mktemp() ...@@ -31,7 +31,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products") TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
def getSchema(): def getSchema():
startup = os.path.dirname(os.path.realpath(Zope.Startup.__file__)) startup = os.path.dirname(os.path.realpath(Zope2.Startup.__file__))
schemafile = os.path.join(startup, 'zopeschema.xml') schemafile = os.path.join(startup, 'zopeschema.xml')
return ZConfig.loadSchema(schemafile) return ZConfig.loadSchema(schemafile)
......
...@@ -22,9 +22,9 @@ import unittest ...@@ -22,9 +22,9 @@ import unittest
import warnings import warnings
import ZConfig import ZConfig
import Zope.Startup import Zope2.Startup
from Zope.Startup import datatypes from Zope2.Startup import datatypes
from App.config import getConfiguration from App.config import getConfiguration
...@@ -32,7 +32,7 @@ TEMPNAME = tempfile.mktemp() ...@@ -32,7 +32,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products") TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
def getSchema(): def getSchema():
startup = os.path.dirname(os.path.realpath(Zope.Startup.__file__)) startup = os.path.dirname(os.path.realpath(Zope2.Startup.__file__))
schemafile = os.path.join(startup, 'zopeschema.xml') schemafile = os.path.join(startup, 'zopeschema.xml')
return ZConfig.loadSchema(schemafile) return ZConfig.loadSchema(schemafile)
...@@ -75,7 +75,7 @@ class TestWarnFilter(unittest.TestCase): ...@@ -75,7 +75,7 @@ class TestWarnFilter(unittest.TestCase):
<warnfilter> <warnfilter>
action error action error
message .*test.* message .*test.*
category Zope.Startup.tests.test_warnfilter.TestSchemaWarning category Zope2.Startup.tests.test_warnfilter.TestSchemaWarning
module .*test_warnfilter.* module .*test_warnfilter.*
lineno 0 lineno 0
</warnfilter> </warnfilter>
...@@ -102,7 +102,7 @@ class TestWarnFilter(unittest.TestCase): ...@@ -102,7 +102,7 @@ class TestWarnFilter(unittest.TestCase):
instancehome <<INSTANCE_HOME>> instancehome <<INSTANCE_HOME>>
<warnfilter> <warnfilter>
action wontwork action wontwork
category Zope.Startup.tests.test_schema.TestSchemaWarning category Zope2.Startup.tests.test_schema.TestSchemaWarning
</warnfilter> </warnfilter>
""") """)
......
...@@ -40,7 +40,7 @@ import sys ...@@ -40,7 +40,7 @@ import sys
import signal import signal
import zdaemon import zdaemon
import Zope.Startup import Zope2.Startup
from zdaemon.zdctl import ZDCmd from zdaemon.zdctl import ZDCmd
from zdaemon.zdoptions import ZDOptions from zdaemon.zdoptions import ZDOptions
...@@ -60,7 +60,7 @@ class ZopeCtlOptions(ZDOptions): ...@@ -60,7 +60,7 @@ class ZopeCtlOptions(ZDOptions):
positional_args_allowed = 1 positional_args_allowed = 1
program = "zopectl" program = "zopectl"
schemadir = os.path.dirname(Zope.Startup.__file__) schemadir = os.path.dirname(Zope2.Startup.__file__)
schemafile = "zopeschema.xml" schemafile = "zopeschema.xml"
uid = gid = None uid = gid = None
...@@ -166,7 +166,7 @@ class ZopeCmd(ZDCmd): ...@@ -166,7 +166,7 @@ class ZopeCmd(ZDCmd):
def do_debug(self, arg): def do_debug(self, arg):
cmdline = self.get_startup_cmd(self.options.python + ' -i', cmdline = self.get_startup_cmd(self.options.python + ' -i',
'import Zope; app=Zope.app()') 'import Zope2; app=Zope2.app()')
print ('Starting debugger (the name "app" is bound to the top-level ' print ('Starting debugger (the name "app" is bound to the top-level '
'Zope object)') 'Zope object)')
os.system(cmdline) os.system(cmdline)
...@@ -194,7 +194,7 @@ class ZopeCmd(ZDCmd): ...@@ -194,7 +194,7 @@ class ZopeCmd(ZDCmd):
if len(tup) > 1: if len(tup) > 1:
argv = tup[1:] argv = tup[1:]
cmd += '[sys.argv.append(x) for x in %s];' % argv cmd += '[sys.argv.append(x) for x in %s];' % argv
cmd += 'import Zope; app=Zope.app(); execfile(\'%s\')' % script cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
cmdline = self.get_startup_cmd(self.options.python, cmd) cmdline = self.get_startup_cmd(self.options.python, cmd)
os.system(cmdline) os.system(cmdline)
...@@ -212,7 +212,7 @@ class ZopeCmd(ZDCmd): ...@@ -212,7 +212,7 @@ class ZopeCmd(ZDCmd):
return return
cmdline = self.get_startup_cmd( cmdline = self.get_startup_cmd(
self.options.python , self.options.python ,
'import Zope; app=Zope.app();' 'import Zope2; app=Zope2.app();'
'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);' 'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);'
'get_transaction().commit()' 'get_transaction().commit()'
) % (name, password) ) % (name, password)
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
# This version is transitional. If you have a script that no longer # This version is transitional. If you have a script that no longer
# works because it needs the database to be opened on calling "import # works because it needs the database to be opened on calling "import
# Zope", you can set the environment variable ZOPE_COMPATIBLE_STARTUP # Zope", you can set the environment variable ZOPE_COMPATIBLE_STARTUP
# to a non-empty value. Then "import Zope" will automatically open # to a non-empty value. Then "import Zope2" will automatically open
# the database as it used to. Or better, update the script to call # the database as it used to. Or better, update the script to call
# Zope.startup() right after importing the Zope package. A future # Zope2.startup() right after importing the Zope package. A future
# version of Zope will remove this backward compatibility, since the # version of Zope will remove this backward compatibility, since the
# old behavior is likely to cause problems as ZODB backends, like ZEO, # old behavior is likely to cause problems as ZODB backends, like ZEO,
# gain new features. # gain new features.
...@@ -43,7 +43,7 @@ def startup(): ...@@ -43,7 +43,7 @@ def startup():
return return
_began_startup = 1 _began_startup = 1
_configure() _configure()
from Zope.App.startup import startup as _startup from Zope2.App.startup import startup as _startup
_startup() _startup()
def app(*args, **kw): def app(*args, **kw):
...@@ -57,7 +57,7 @@ def debug(*args, **kw): ...@@ -57,7 +57,7 @@ def debug(*args, **kw):
import ZPublisher import ZPublisher
return ZPublisher.test('Zope', *args, **kw) return ZPublisher.test('Zope', *args, **kw)
from Zope.Startup.run import configure from Zope2.Startup.run import configure
def _configure(): def _configure():
# Load configuration file from (optional) environment variable # Load configuration file from (optional) environment variable
...@@ -67,7 +67,7 @@ def _configure(): ...@@ -67,7 +67,7 @@ def _configure():
if configfile is not None: if configfile is not None:
configure(configfile) configure(configfile)
# Zope.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
bobo_application = None bobo_application = None
zpublisher_transactions_manager = None zpublisher_transactions_manager = 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