from paste import httpexceptions from paste.registry import RegistryManager from paste.deploy.converters import asbool from turbogears.cputils import Tree, start_cp_engine from turbogears.middleware import ErrorHandler, make_config_filter from ${package}.controllers import Root def make_app(global_conf, full_stack=True, **app_conf): """This function is a paste.app_factory entry_point which will take care of building your WSGI application object.""" tree = Tree() tree.mount(Root(), '/') # You can mount other CP/WSGI applications here # Establish the ConfigMiddleware for this application app_conf['request.throw_errors'] = True app = make_config_filter(tree, global_conf, **app_conf) # YOUR MIDDLEWARE # Put your own middleware here, so that any problems are caught by the # error handling middleware underneath if asbool(full_stack): app = httpexceptions.make_middleware(app, global_conf) app = ErrorHandler(app, global_conf) # Establish the Registry for this application app = RegistryManager(app) # Start the CP engine if it's not started already start_cp_engine() return app