Stickum

Stickum, your family will love you.
Python code pasted @ 15:09 on Fri, 05 Jan 07
Copy & Paste Plain Text
1
from paste import httpexceptions
2
from paste.registry import RegistryManager
3
from paste.deploy.converters import asbool
4
from turbogears.cputils import Tree, start_cp_engine
5
from turbogears.middleware import ErrorHandler, make_config_filter
6
7
from ${package}.controllers import Root
8
9
10
def make_app(global_conf, full_stack=True, **app_conf):
11
    """This function is a paste.app_factory entry_point which will take care
12
    of building your WSGI application object."""
13
14
    tree = Tree()
15
    tree.mount(Root(), '/')
16
17
    # You can mount other CP/WSGI applications here
18
19
20
    # Establish the ConfigMiddleware for this application
21
    app_conf['request.throw_errors'] = True
22
    app = make_config_filter(tree, global_conf, **app_conf)
23
24
    # YOUR MIDDLEWARE
25
    # Put your own middleware here, so that any problems are caught by the 
26
    # error handling middleware underneath
27
    
28
    if asbool(full_stack):
29
        app = httpexceptions.make_middleware(app, global_conf)
30
        app = ErrorHandler(app, global_conf)
31
32
    # Establish the Registry for this application
33
    app = RegistryManager(app)
34
35
    # Start the CP engine if it's not started already
36
    start_cp_engine()
37
    return app