Ignore:
Timestamp:
Feb 23, 2009, 6:42:45 PM (16 years ago)
Author:
Edward Z. Yang <edwardzyang@…>
Branches:
master, debian, mac, no-cups, web
Children:
b748ed1
Parents:
77aa4c8
git-author:
Edward Z. Yang <edwardzyang@…> (02/23/09 18:42:45)
git-committer:
Edward Z. Yang <edwardzyang@…> (02/23/09 18:42:45)
Message:

Make sipbmp3web work on scripts.

Signed-off-by: Edward Z. Yang <edwardzyang@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gutenbach-web/middleware.py

    r973dd91 r7f1e63c  
    22from sipbmp3web.config.app_cfg import base_config
    33from sipbmp3web.config.environment import load_environment
     4import subprocess, os
     5from pylons import config
    46
    57#Use base_config to setup the necessary WSGI App factory.
     
    79make_base_app = base_config.setup_tg_wsgi_app(load_environment)
    810
     11class FastCGIFixMiddleware(object):
     12    """Remove dispatch.fcgi from the SCRIPT_NAME
     13   
     14    mod_rewrite doesn't do a perfect job of hiding it's actions to the
     15    underlying script, which causes TurboGears to get confused and tack
     16    on dispatch.fcgi when it really shouldn't. This fixes that problem as a
     17    Middleware that fiddles with the appropriate environment variable
     18    before any processing takes place.
     19    """
     20    def __init__(self, app, global_conf=None):
     21        self.app = app
     22    def __call__(self, environ, start_response):
     23        environ['SCRIPT_NAME'] = environ['SCRIPT_NAME'].replace('/dispatch.fcgi', '')
     24        return self.app(environ, start_response)
     25
     26class KinitMiddleware(object):
     27    """Performs Kerberos authentication with a keytab"""
     28    def __init__(self, app, global_conf=None):
     29        self.app = app
     30        self.keytab = config["keytab"]
     31    def __call__(self, environ, start_response):
     32        if self.keytab:
     33            subprocess.call(["/usr/kerberos/bin/kinit", "ezyang/extra", "-k", "-t", self.keytab])
     34        return self.app(environ, start_response)
     35
    936def make_app(global_conf, full_stack=True, **app_conf):
    1037    app = make_base_app(global_conf, full_stack=True, **app_conf)
    11     #Wrap your base turbogears app with custom middleware
     38    app = FastCGIFixMiddleware(app, global_conf)
     39    app = KinitMiddleware(app, global_conf)
    1240    return app
    1341
Note: See TracChangeset for help on using the changeset viewer.