# -*- coding: utf-8 -*- ''' Includes a version of mpcp.py, to allow it to be used with mod_python/Apache. You can start the applications with their own build-in CherryPy server with just: %> python root.py Or you can configure Apache to use mod_python to do this. ** * Make sure server.environment is set to "production" ** A sample http.conf file looks like this: ---------------------------------------- # mount the application wherever you want. For example at /synth-ui # You will have to specify this in the system configurations, too! SetHandler mod_python PythonPath "[''] + sys.path" PythonHandler mpcp PythonOption cherrysetup serverStarter::configureServer PythonOption sys.path 'lib' PythonAutoReload Off PythonDebug On ''' import logging, logging.config, os, sys, cherrypy import annofeed,configuration cfgObj = configuration.getConfigObj() #------------------------------------------------------------------------------- #Server stuff #------------------------------------------------------------------------------- def configureServer(): """Configure CP server settings dynamically depending upon the tapir config settings. All other "static" configurations are inside the webapp/root.cfg ini file. """ confFile = "%s/server.cfg" % cfgObj.homeLocator configMap = cherrypy.config.dict_from_config_file(confFile) cherrypy.tree.mount(annofeed.Site(), baseurl='annotation', conf=configMap) cherrypy.config.update({'global' : {'server.log_file' : '%s/cp_server.log'% cfgObj.homeLocator, } }) def configureDevServer(): """mod_python server testing with autoreload, etc""" configureServer(port) cherrypy.config.update({'global' : { 'server.environment' : 'development', 'server.show_tracebacks' : True, 'server.log_to_screen' : True, } }) #------------------------------------------------------------------------------- #Standalone stuff #------------------------------------------------------------------------------- if __name__ == '__main__': # try to find custom port if len(sys.argv)>1 and sys.argv[1].isdigit(): configureDevServer(int(sys.argv[1])) else: configureDevServer() cherrypy.server.start()