Beispiel #1
0
def start():

    parser = OptionParser(version="%s" % (openobject.release.version))
    parser.add_option("-c",
                      "--config",
                      metavar="FILE",
                      dest="config",
                      help="configuration file",
                      default=get_config_file())
    parser.add_option("-a",
                      "--address",
                      help="host address, overrides server.socket_host")
    parser.add_option("-p",
                      "--port",
                      help="port number, overrides server.socket_port")
    parser.add_option("--no-static",
                      dest="static",
                      action="store_false",
                      default=True,
                      help="Disables serving static files through CherryPy")
    options, args = parser.parse_args(sys.argv)

    if not os.path.exists(options.config):
        raise ConfigurationError(
            _("Could not find configuration file: %s") % options.config)

    app_config = as_dict(options.config)

    openobject.configure(app_config)
    if options.static:
        openobject.enable_static_paths()

    if options.address:
        cherrypy.config['server.socket_host'] = options.address
    if options.port:
        try:
            cherrypy.config['server.socket_port'] = int(options.port)
        except:
            pass

    configure_babel()

    cherrypy.engine.start()
    cherrypy.engine.block()
Beispiel #2
0
import glob
import sys
import os

sys.path.insert(0, os.path.dirname(__file__))

from cherrypy._cpconfig import as_dict
import openobject

conf = as_dict(os.path.join(os.path.dirname(__file__), 'doc', 'openerp-web.cfg'))
openobject.configure(conf)
openobject.enable_static_paths() # serve static file via the wsgi server

application = openobject.application