comparison pylons_app/config/middleware.py @ 41:71ffa932799d

Added app basic auth. Changed few deprecations for new pylons. added sqlite logging for user actions.
author Marcin Kuzminski <marcin@python-blog.com>
date Wed, 07 Apr 2010 00:51:55 +0200
parents 2963f2894a7a
children 2e1247e62c5b
comparison
equal deleted inserted replaced
40:cbc1624cb499 41:71ffa932799d
6 from paste.deploy.converters import asbool 6 from paste.deploy.converters import asbool
7 from pylons import config 7 from pylons import config
8 from pylons.middleware import ErrorHandler, StatusCodeRedirect 8 from pylons.middleware import ErrorHandler, StatusCodeRedirect
9 from pylons.wsgiapp import PylonsApp 9 from pylons.wsgiapp import PylonsApp
10 from routes.middleware import RoutesMiddleware 10 from routes.middleware import RoutesMiddleware
11 11 from paste.auth.basic import AuthBasicHandler
12 from pylons_app.config.environment import load_environment 12 from pylons_app.config.environment import load_environment
13 13 from pylons_app.lib.auth import authfunc
14 14
15 def make_app(global_conf, full_stack=True, **app_conf): 15 def make_app(global_conf, full_stack=True, **app_conf):
16 """Create a Pylons WSGI application and return it 16 """Create a Pylons WSGI application and return it
17 17
18 ``global_conf`` 18 ``global_conf``
41 41
42 # Routing/Session/Cache Middleware 42 # Routing/Session/Cache Middleware
43 app = RoutesMiddleware(app, config['routes.map']) 43 app = RoutesMiddleware(app, config['routes.map'])
44 app = SessionMiddleware(app, config) 44 app = SessionMiddleware(app, config)
45 app = CacheMiddleware(app, config) 45 app = CacheMiddleware(app, config)
46 46 app = AuthBasicHandler(app, config['repos_name'] + ' mercurial repository', authfunc)
47
47 if asbool(full_stack): 48 if asbool(full_stack):
48 # Handle Python exceptions 49 # Handle Python exceptions
49 app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 50 app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
50 51
51 # Display error documents for 401, 403, 404 status codes (and 52 # Display error documents for 401, 403, 404 status codes (and
53 if asbool(config['debug']): 54 if asbool(config['debug']):
54 #don't handle 404, since mercurial does it for us. 55 #don't handle 404, since mercurial does it for us.
55 app = StatusCodeRedirect(app, [400, 401, 403, 500]) 56 app = StatusCodeRedirect(app, [400, 401, 403, 500])
56 else: 57 else:
57 app = StatusCodeRedirect(app, [400, 401, 403, 500]) 58 app = StatusCodeRedirect(app, [400, 401, 403, 500])
58 59
59 # Establish the Registry for this application 60 # Establish the Registry for this application
60 app = RegistryManager(app) 61 app = RegistryManager(app)
61 62
62 # Static files (If running in production, and Apache or another web 63 # Static files (If running in production, and Apache or another web
63 # server is handling this static content, remove the following 3 lines) 64 # server is handling this static content, remove the following 3 lines)