1
# -*- coding: utf-8 -*-
2
"""This module contains functions called from console script entry points."""
7
from os.path import dirname, exists, join
10
pkg_resources.require("TurboGears")
15
cherrypy.lowercase_api = True
17
class ConfigurationError(Exception):
21
"""Start the CherryPy application server."""
23
setupdir = dirname(dirname(__file__))
26
# First look on the command line for a desired config file,
27
# if it's not on the command line, then look for 'setup.py'
28
# in the current directory. If there, load configuration
29
# from a file called 'dev.cfg'. If it's not there, the project
30
# is probably installed and we'll look first for a file called
31
# 'prod.cfg' in the current directory and then for a default
32
# config file called 'default.cfg' packaged in the egg.
34
configfile = sys.argv[1]
35
elif exists(join(setupdir, "setup.py")):
36
configfile = join(setupdir, "dev.cfg")
37
elif exists(join(curdir, "prod.cfg")):
38
configfile = join(curdir, "prod.cfg")
41
configfile = pkg_resources.resource_filename(
42
pkg_resources.Requirement.parse("tgpisa"),
44
except pkg_resources.DistributionNotFound:
45
raise ConfigurationError("Could not find default configuration.")
47
turbogears.update_config(configfile=configfile,
48
modulename="tgpisa.config")
50
from tgpisa.controllers import Root
52
turbogears.start_server(Root())