#!/usr/bin/python
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
"""Script to run the Zope Application Server in the foreground.

$Id$
"""
import os
import sys


SOFTWARE_HOME = r"/usr/lib/python2.4/site-packages"
INSTANCE_HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
CONFIG_FILE = os.path.join(INSTANCE_HOME, "etc", "zdaemon.conf")


def run():
    # This removes the script directory from sys.path, which we do
    # since there are no modules here.
    #
    basepath = filter(None, sys.path)

    sys.path[:] = [os.path.join(INSTANCE_HOME, "lib", "python"),
                   SOFTWARE_HOME] + basepath

    import zope.app.twisted.controller
    zope.app.twisted.controller.INSTANCE_HOME = INSTANCE_HOME
    zope.app.twisted.controller.main(["-C", CONFIG_FILE] + sys.argv[1:])


if __name__ == '__main__':
    run()
