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 @@
# 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
......@@ -33,7 +33,7 @@ import os
import sys
import ZODB
import ZODB.ZApplication
import Zope
import Zope2
import ZPublisher
......@@ -58,7 +58,7 @@ def startup():
DB = configuration.dbtab.getDatabase('/', is_root=1)
Globals.BobobaseName = DB.getName()
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'):
DB=m.DB
else:
......@@ -66,14 +66,14 @@ def startup():
DB = ZODB.DB(storage)
Globals.BobobaseName = DB.getName()
sys.modules['Zope.custom_zodb']=m
sys.modules['Zope2.custom_zodb']=m
if DB.getActivityMonitor() is None:
from ZODB.ActivityMonitor import ActivityMonitor
DB.setActivityMonitor(ActivityMonitor())
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:
Globals.UndoManager=DB
......@@ -90,7 +90,7 @@ def startup():
app = ZODB.ZApplication.ZApplicationWrapper(
DB, 'Application', OFS.Application.Application, (),
Globals.VersionNameName)
Zope.bobo_application = app
Zope2.bobo_application = app
# Initialize the app object
application = app()
......@@ -104,17 +104,13 @@ def startup():
# "Log off" as system user
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
startup_time = log_time()
Zope.zpublisher_transactions_manager = TransactionsManager()
Zope.zpublisher_exception_hook = zpublisher_exception_hook
Zope.zpublisher_validated_hook = validated_hook
Zope.__bobo_before__ = noSecurityManager
Zope2.zpublisher_transactions_manager = TransactionsManager()
Zope2.zpublisher_exception_hook = zpublisher_exception_hook
Zope2.zpublisher_validated_hook = validated_hook
Zope2.__bobo_before__ = noSecurityManager
def validated_hook(request, user):
......@@ -129,7 +125,7 @@ def validated_hook(request, user):
expires="Mon, 25-Jan-1999 23:59:59 GMT",
path=(request['BASEPATH1'] or '/'),
)
Zope.DB.removeVersionPool(version)
Zope2.DB.removeVersionPool(version)
raise Unauthorized, "You don't have permission to enter versions."
......
......@@ -252,8 +252,8 @@ class ZopeStarter:
def startZope(self):
# Import Zope
import Zope
Zope.startup()
import Zope2
Zope2.startup()
def makeLockFile(self):
if not self.cfg.zserver_read_only_mode:
......@@ -268,7 +268,7 @@ class ZopeStarter:
# if we can't lock it.
# we need a separate lock file because on win32, locks are not
# 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
try:
if os.path.exists(lock_filename):
......
......@@ -14,8 +14,8 @@
def run():
""" Start a Zope instance """
import Zope.Startup
starter = Zope.Startup.get_starter()
import Zope2.Startup
starter = Zope2.Startup.get_starter()
opts = _setconfig()
starter.setConfiguration(opts.configroot)
starter.prepare()
......@@ -23,11 +23,11 @@ def run():
def configure(configfile):
""" Provide an API which allows scripts like zopectl to configure
Zope before attempting to do 'app = Zope.app(). Should be used as
follows: from Zope.Startup.run import configure;
configure('/path/to/configfile'); import Zope; app = Zope.app() """
import Zope.Startup
starter = Zope.Startup.get_starter()
Zope before attempting to do 'app = Zope2.app(). Should be used as
follows: from Zope2.Startup.run import configure;
configure('/path/to/configfile'); import Zope2; app = Zope2.app() """
import Zope2.Startup
starter = Zope2.Startup.get_starter()
opts = _setconfig(configfile)
starter.setConfiguration(opts.configroot)
starter.setupSecurityOptions()
......@@ -38,7 +38,7 @@ def _setconfig(configfile=None):
""" Configure a Zope instance based on ZopeOptions. Optionally
accept a configfile argument (string path) in order to specify
where the configuration file exists. """
from Zope.Startup import options, handlers
from Zope2.Startup import options, handlers
from App import config
opts = options.ZopeOptions()
if configfile:
......
......@@ -12,4 +12,4 @@
#
##############################################################################
"""Tests of the Zope.Startup package."""
"""Tests of the Zope2.Startup package."""
......@@ -25,7 +25,7 @@ import ZConfig
from ZConfig.components.logger.tests import test_logger
from ZConfig.components.logger.loghandler import NullHandler
import Zope.Startup
import Zope2.Startup
from App.config import getConfiguration, setConfiguration
......@@ -33,7 +33,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
def getSchema():
startup = os.path.dirname(Zope.Startup.__file__)
startup = os.path.dirname(Zope2.Startup.__file__)
schemafile = os.path.join(startup, 'zopeschema.xml')
return ZConfig.loadSchema(schemafile)
......@@ -70,7 +70,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
logger.__dict__.update(logger_states[name])
def get_starter(self, conf):
starter = Zope.Startup.get_starter()
starter = Zope2.Startup.get_starter()
starter.setConfiguration(conf)
return starter
......
......@@ -20,9 +20,9 @@ import tempfile
import unittest
import ZConfig
import Zope.Startup
import Zope2.Startup
from Zope.Startup import datatypes
from Zope2.Startup import datatypes
from App.config import getConfiguration
......@@ -31,7 +31,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
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')
return ZConfig.loadSchema(schemafile)
......
......@@ -22,9 +22,9 @@ import unittest
import warnings
import ZConfig
import Zope.Startup
import Zope2.Startup
from Zope.Startup import datatypes
from Zope2.Startup import datatypes
from App.config import getConfiguration
......@@ -32,7 +32,7 @@ TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
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')
return ZConfig.loadSchema(schemafile)
......@@ -75,7 +75,7 @@ class TestWarnFilter(unittest.TestCase):
<warnfilter>
action error
message .*test.*
category Zope.Startup.tests.test_warnfilter.TestSchemaWarning
category Zope2.Startup.tests.test_warnfilter.TestSchemaWarning
module .*test_warnfilter.*
lineno 0
</warnfilter>
......@@ -102,7 +102,7 @@ class TestWarnFilter(unittest.TestCase):
instancehome <<INSTANCE_HOME>>
<warnfilter>
action wontwork
category Zope.Startup.tests.test_schema.TestSchemaWarning
category Zope2.Startup.tests.test_schema.TestSchemaWarning
</warnfilter>
""")
......
......@@ -40,7 +40,7 @@ import sys
import signal
import zdaemon
import Zope.Startup
import Zope2.Startup
from zdaemon.zdctl import ZDCmd
from zdaemon.zdoptions import ZDOptions
......@@ -60,7 +60,7 @@ class ZopeCtlOptions(ZDOptions):
positional_args_allowed = 1
program = "zopectl"
schemadir = os.path.dirname(Zope.Startup.__file__)
schemadir = os.path.dirname(Zope2.Startup.__file__)
schemafile = "zopeschema.xml"
uid = gid = None
......@@ -166,7 +166,7 @@ class ZopeCmd(ZDCmd):
def do_debug(self, arg):
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 '
'Zope object)')
os.system(cmdline)
......@@ -194,7 +194,7 @@ class ZopeCmd(ZDCmd):
if len(tup) > 1:
argv = tup[1:]
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)
os.system(cmdline)
......@@ -212,7 +212,7 @@ class ZopeCmd(ZDCmd):
return
cmdline = self.get_startup_cmd(
self.options.python ,
'import Zope; app=Zope.app();'
'import Zope2; app=Zope2.app();'
'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);'
'get_transaction().commit()'
) % (name, password)
......
......@@ -26,9 +26,9 @@
# This version is transitional. If you have a script that no longer
# works because it needs the database to be opened on calling "import
# 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
# 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
# old behavior is likely to cause problems as ZODB backends, like ZEO,
# gain new features.
......@@ -43,7 +43,7 @@ def startup():
return
_began_startup = 1
_configure()
from Zope.App.startup import startup as _startup
from Zope2.App.startup import startup as _startup
_startup()
def app(*args, **kw):
......@@ -57,7 +57,7 @@ def debug(*args, **kw):
import ZPublisher
return ZPublisher.test('Zope', *args, **kw)
from Zope.Startup.run import configure
from Zope2.Startup.run import configure
def _configure():
# Load configuration file from (optional) environment variable
......@@ -67,7 +67,7 @@ def _configure():
if configfile is not None:
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
bobo_application = 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