Skip to content

Commit

Permalink
Merge branch 'pep8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Oct 11, 2012
2 parents 06285bb + b1f6932 commit 07d14f5
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 56 deletions.
42 changes: 21 additions & 21 deletions ckan/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ckan.config.environment import load_environment
import ckan.lib.app_globals as app_globals


def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
"""Create a Pylons WSGI application and return it
Expand Down Expand Up @@ -64,30 +65,29 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
app = CacheMiddleware(app, config)

# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
#app = QueueLogMiddleware(app)

# Fanstatic
if asbool(config.get('debug', False)):
fanstatic_config = {
'versioning' : True,
'recompute_hashes' : True,
'minified' : False,
'bottom' : True,
'bundle' : False,
'versioning': True,
'recompute_hashes': True,
'minified': False,
'bottom': True,
'bundle': False,
}
else:
fanstatic_config = {
'versioning' : True,
'recompute_hashes' : False,
'minified' : True,
'bottom' : True,
'bundle' : True,
'versioning': True,
'recompute_hashes': False,
'minified': True,
'bottom': True,
'bundle': True,
}
app = Fanstatic(app, **fanstatic_config)


if asbool(full_stack):
# Handle Python exceptions
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
Expand All @@ -98,15 +98,15 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
app = StatusCodeRedirect(app, [400, 404])
else:
app = StatusCodeRedirect(app, [400, 404, 500])

# Initialize repoze.who
who_parser = WhoConfig(global_conf['here'])
who_parser.parse(open(app_conf['who.config_file']))

if asbool(config.get('openid_enabled', 'true')):
from repoze.who.plugins.openid.identification import OpenIdIdentificationPlugin
# Monkey patches for repoze.who.openid
# Fixes #1659 - enable log-out when CKAN mounted at non-root URL
# Fixes #1659 - enable log-out when CKAN mounted at non-root URL
from ckan.lib import repoze_patch
OpenIdIdentificationPlugin.identify = repoze_patch.identify
OpenIdIdentificationPlugin.redirect_to_logged_in = repoze_patch.redirect_to_logged_in
Expand All @@ -117,7 +117,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
not isinstance(i, OpenIdIdentificationPlugin)]
who_parser.challengers = [i for i in who_parser.challengers if \
not isinstance(i, OpenIdIdentificationPlugin)]

app = PluggableAuthenticationMiddleware(app,
who_parser.identifiers,
who_parser.authenticators,
Expand All @@ -126,10 +126,10 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
who_parser.request_classifier,
who_parser.challenge_decider,
logging.getLogger('repoze.who'),
logging.WARN, # ignored
logging.WARN, # ignored
who_parser.remote_user_key,
)

# Establish the Registry for this application
app = RegistryManager(app)

Expand All @@ -152,7 +152,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
StaticURLParser(public_path.strip(),
cache_max_age=static_max_age)
)
app = Cascade(extra_static_parsers+static_parsers)
app = Cascade(extra_static_parsers + static_parsers)

# Page cache
if asbool(config.get('ckan.page_cache_enabled')):
Expand All @@ -164,6 +164,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):

return app


class I18nMiddleware(object):
"""I18n Middleware selects the language based on the url
eg /fr/home is French"""
Expand Down Expand Up @@ -198,7 +199,7 @@ def __call__(self, environ, start_response):
# Current application url
path_info = environ['PATH_INFO']
# sort out weird encodings
path_info = '/'.join(urllib.quote(pce,'') for pce in path_info.split('/'))
path_info = '/'.join(urllib.quote(pce, '') for pce in path_info.split('/'))

qs = environ.get('QUERY_STRING')

Expand Down Expand Up @@ -317,7 +318,6 @@ def __init__(self, app, config):
self.app = app
self.engine = sa.create_engine(config.get('sqlalchemy.url'))


def __call__(self, environ, start_response):
path = environ['PATH_INFO']
if path == '/_tracking':
Expand Down

0 comments on commit 07d14f5

Please sign in to comment.