ovirt-node 2.2.0 release
[ovirt-node.git] / server / ovirtserver / config / middleware.py
blobb5f47dadca0c9f63c5befc2586b7a3c090717b72
1 # Copyright (C) 2010, Red Hat, Inc.
2 # Written by Darryl L. Pierce
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 """WSGI middleware initialization for the server application."""
20 from ovirtserver.config.app_cfg import base_config
21 from ovirtserver.config.environment import load_environment
24 __all__ = ['make_app']
26 # Use base_config to setup the necessary PasteDeploy application factory.
27 # make_base_app will wrap the TG2 app with all the middleware it needs.
28 make_base_app = base_config.setup_tg_wsgi_app(load_environment)
31 def make_app(global_conf, full_stack=True, **app_conf):
32 """
33 Set server up with the settings found in the PasteDeploy configuration
34 file used.
36 :param global_conf: The global settings for server (those
37 defined under the ``[DEFAULT]`` section).
38 :type global_conf: dict
39 :param full_stack: Should the whole TG2 stack be set up?
40 :type full_stack: str or bool
41 :return: The server application with all the relevant middleware
42 loaded.
44 This is the PasteDeploy factory for the server application.
46 ``app_conf`` contains all the application-specific settings (those defined
47 under ``[app:main]``.
50 """
51 app = make_base_app(global_conf, full_stack=True, **app_conf)
53 # Wrap your base TurboGears 2 application with custom middleware here
55 return app