Commit db6b57b7 authored by Fred Drake's avatar Fred Drake

- update to use new App.config module

- remove some additional cruftiness from the code
parent 057c7730
...@@ -236,12 +236,14 @@ import sys ...@@ -236,12 +236,14 @@ import sys
# happened, then the path munging code is skipped. # happened, then the path munging code is skipped.
swhome=r'INSERT_SOFTWARE_HOME' swhome=r'INSERT_SOFTWARE_HOME'
if swhome != 'INSERT_SOFTWARE_HOME': if swhome != 'INSERT_SOFTWARE_HOME':
sys.path.insert(0, '%s/lib/python' % swhome) sys.path[:0] = [
sys.path.insert(1, '%s/bin/lib' % swhome) swhome + '/lib/python',
sys.path.insert(2, '%s/bin/lib/plat-win' % swhome) swhome + '/bin/lib',
sys.path.insert(3, '%s/bin/lib/win32' % swhome) swhome + '/bin/lib/plat-win',
sys.path.insert(4, '%s/bin/lib/win32/lib' % swhome) swhome + '/bin/lib/win32',
sys.path.insert(5, swhome) swhome + '/bin/lib/win32/lib',
swhome,
]
import codecs import codecs
...@@ -527,7 +529,7 @@ import zdaemon.Daemon ...@@ -527,7 +529,7 @@ import zdaemon.Daemon
# Import ZServer before we open the database or get at interesting # Import ZServer before we open the database or get at interesting
# application code so that ZServer's asyncore gets to be the # application code so that ZServer's asyncore gets to be the
# official one. Also gets SOFTWARE_HOME, INSTANCE_HOME, and CLIENT_HOME # official one.
import ZServer import ZServer
# install signal handlers if on posix # install signal handlers if on posix
...@@ -535,10 +537,13 @@ if os.name == 'posix': ...@@ -535,10 +537,13 @@ if os.name == 'posix':
from Signals import Signals from Signals import Signals
Signals.registerZopeSignals() Signals.registerZopeSignals()
import App.config
cfg = App.config.getConfiguration()
# Location of the ZServer pid file. When Zope starts up it will write # Location of the ZServer pid file. When Zope starts up it will write
# its PID to this file. If Zope is run under zdaemon control, zdaemon # its PID to this file. If Zope is run under zdaemon control, zdaemon
# will write to this pidfile instead of Zope. # will write to this pidfile instead of Zope.
PID_FILE=os.path.join(CLIENT_HOME, 'Z2.pid') PID_FILE=os.path.join(cfg.clienthome, 'Z2.pid')
# Import logging support # Import logging support
import zLOG import zLOG
...@@ -548,14 +553,13 @@ if not READ_ONLY: ...@@ -548,14 +553,13 @@ if not READ_ONLY:
zLOG.initialize() zLOG.initialize()
if USE_DAEMON and not READ_ONLY: if USE_DAEMON and not READ_ONLY:
import App.FindHomes
sys.ZMANAGED=1 sys.ZMANAGED=1
# zdaemon.run creates a process which "manages" the actual Zope # zdaemon.run creates a process which "manages" the actual Zope
# process (restarts it if it dies). The management process passes along # process (restarts it if it dies). The management process passes along
# signals that it receives to its child. # signals that it receives to its child.
zdaemon.Daemon.run(sys.argv, os.path.join(CLIENT_HOME, PID_FILE)) zdaemon.Daemon.run(sys.argv, os.path.join(cfg.clienthome, PID_FILE))
os.chdir(CLIENT_HOME) os.chdir(cfg.clienthome)
def _warn_nobody(): def _warn_nobody():
zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise "
...@@ -565,7 +569,7 @@ def _warn_nobody(): ...@@ -565,7 +569,7 @@ def _warn_nobody():
try: try:
if DETAILED_LOG_FILE: if DETAILED_LOG_FILE:
from ZServer import DebugLogger from ZServer import DebugLogger
logfile=os.path.join(CLIENT_HOME, DETAILED_LOG_FILE) logfile=os.path.join(cfg.clienthome, DETAILED_LOG_FILE)
zLOG.LOG('z2', zLOG.BLATHER, zLOG.LOG('z2', zLOG.BLATHER,
'Using detailed request log file %s' % logfile) 'Using detailed request log file %s' % logfile)
DL=DebugLogger.DebugLogger(logfile) DL=DebugLogger.DebugLogger(logfile)
...@@ -584,7 +588,7 @@ try: ...@@ -584,7 +588,7 @@ try:
# You may wish to create different logs for different servers. See # You may wish to create different logs for different servers. See
# medusa/logger.py for more information. # medusa/logger.py for more information.
if not os.path.isabs(LOG_FILE): if not os.path.isabs(LOG_FILE):
LOG_PATH=os.path.join(CLIENT_HOME, LOG_FILE) LOG_PATH=os.path.join(cfg.clienthome, LOG_FILE)
else: else:
LOG_PATH=LOG_FILE LOG_PATH=LOG_FILE
...@@ -841,7 +845,7 @@ try: ...@@ -841,7 +845,7 @@ try:
'to; fix this to start as root (see ' 'to; fix this to start as root (see '
'doc/SETUID.txt)') 'doc/SETUID.txt)')
import stat import stat
client_home_stat = os.stat(CLIENT_HOME) client_home_stat = os.stat(cfg.clienthome)
client_home_faults = [] client_home_faults = []
if not (client_home_stat[stat.ST_MODE]&01000): if not (client_home_stat[stat.ST_MODE]&01000):
client_home_faults.append('does not have the sticky bit set') client_home_faults.append('does not have the sticky bit set')
...@@ -850,7 +854,7 @@ try: ...@@ -850,7 +854,7 @@ try:
if client_home_faults: if client_home_faults:
client_home_faults.append('fix this to start as root (see ' client_home_faults.append('fix this to start as root (see '
'doc/SETUID.txt)') 'doc/SETUID.txt)')
err = '%s %s' % (CLIENT_HOME, ', '.join(client_home_faults)) err = '%s %s' % (cfg.clienthome, ', '.join(client_home_faults))
raise SystemExit, err raise SystemExit, err
try: try:
......
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