source: DPPP/kml/csml2kml/python/csml2kmlpylon/csml2kmlpylon/config/middleware.py @ 3633

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/kml/csml2kml/python/csml2kmlpylon/csml2kmlpylon/config/middleware.py@3633
Revision 3633, 2.1 KB checked in by mkochan, 11 years ago (diff)

Finished listing of features according to collection times (only those features are listed which are available during the whole interval. Also, add more detailed error messages.

Line 
1"""Pylons middleware initialization"""
2from paste.cascade import Cascade
3from paste.registry import RegistryManager
4from paste.urlparser import StaticURLParser
5from paste.deploy.converters import asbool
6
7from pylons import config
8from pylons.error import error_template
9from pylons.middleware import error_mapper, ErrorDocuments, ErrorHandler, \
10    StaticJavascripts
11from pylons.wsgiapp import PylonsApp
12
13from csml2kmlpylon.config.environment import load_environment
14
15def make_app(global_conf, full_stack=True, **app_conf):
16    """Create a Pylons WSGI application and return it
17
18    ``global_conf``
19        The inherited configuration for this application. Normally from
20        the [DEFAULT] section of the Paste ini file.
21
22    ``full_stack``
23        Whether or not this application provides a full WSGI stack (by
24        default, meaning it handles its own exceptions and errors).
25        Disable full_stack when this application is "managed" by
26        another WSGI middleware.
27
28    ``app_conf``
29        The application's local configuration. Normally specified in the
30        [app:<name>] section of the Paste ini file (where <name>
31        defaults to main).
32    """
33    # Configure the Pylons environment
34    load_environment(global_conf, app_conf)
35
36    # The Pylons WSGI app
37    app = PylonsApp()
38
39    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
40
41    if asbool(full_stack):
42        # Handle Python exceptions
43        app = ErrorHandler(app, global_conf, error_template=error_template,
44                           **config['pylons.errorware'])
45
46        # Display error documents for 401, 403, 404 status codes (and
47        # 500 when debug is disabled)
48        # -- commented out by Martin Kochan, 17/03/2008
49        # -- to display details in HTTP 404 error messages
50        # app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
51
52    # Establish the Registry for this application
53    app = RegistryManager(app)
54
55    # Static files
56    javascripts_app = StaticJavascripts()
57    static_app = StaticURLParser(config['pylons.paths']['static_files'])
58    app = Cascade([static_app, javascripts_app, app])
59    return app
Note: See TracBrowser for help on using the repository browser.