Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Copy over some changes to the stock template from BlueRhapsody

  • Loading branch information...
commit 58a3e99944ba13a924cb7480da9b3b6e84b1ac66 1 parent f881499
@ebroder authored
View
13 bluechips/config/middleware.py
@@ -9,6 +9,9 @@
StatusCodeRedirect
from pylons.wsgiapp import PylonsApp
from routes.middleware import RoutesMiddleware
+from paste import httpexceptions
+
+from tw.api import make_middleware
from bluechips.config.environment import load_environment
@@ -37,12 +40,19 @@ def make_app(global_conf, full_stack=True, **app_conf):
app = PylonsApp()
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
+ app = httpexceptions.make_middleware(app, global_conf)
# Routing/Session/Cache Middleware
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
app = CacheMiddleware(app, config)
+ app = make_middleware(app, {
+ 'toscawidgets.framework': 'pylons',
+ 'toscawidgets.framework.default_view': 'mako',
+ 'toscawidgets.middleware.inject_resources': True
+ })
+
if asbool(full_stack):
# Handle Python exceptions
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
@@ -59,7 +69,6 @@ def make_app(global_conf, full_stack=True, **app_conf):
# Static files (If running in production, and Apache or another web
# server is handling this static content, remove the following 3 lines)
- javascripts_app = StaticJavascripts()
static_app = StaticURLParser(config['pylons.paths']['static_files'])
- app = Cascade([static_app, javascripts_app, app])
+ app = Cascade([static_app, app])
return app
View
5 bluechips/config/routing.py
@@ -19,8 +19,9 @@ def make_map():
# CUSTOM ROUTES HERE
- map.connect('/:controller/index', action='index')
- map.connect('/:controller/:action/')
+ map.connect('/:controller')
+ map.connect('/:controller/', action='index')
+ map.connect('/:controller/:action')
map.connect('/:controller/:action/:id')
return map
View
22 bluechips/lib/base.py
@@ -2,11 +2,19 @@
Provides the BaseController class for subclassing.
"""
+from pylons import tmpl_context as c
from pylons.controllers import WSGIController
-from pylons.templating import render_mako as render
+from pylons.i18n import _, ungettext, N_
+from tw.mods.pylonshf import render, render_response, validate
+
+import bluechips.lib.helpers as h
+from bluechips import model
from bluechips.model import meta
+from paste.request import construct_url
+from paste.httpexceptions import HTTPMovedPermanently
+
class BaseController(WSGIController):
def __call__(self, environ, start_response):
@@ -14,8 +22,18 @@ def __call__(self, environ, start_response):
# WSGIController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
+ if environ['pylons.routes_dict']['controller'] != 'error':
+ if environ['PATH_INFO'].endswith('/index'):
+ environ['PATH_INFO'] = environ['PATH_INFO'][:-5]
+ raise HTTPMovedPermanently(construct_url(environ))
+ if not environ['PATH_INFO'].endswith('/') and \
+ environ['pylons.routes_dict']['action'] is 'index':
+ environ['PATH_INFO'] += '/'
+ raise HTTPMovedPermanently(construct_url(environ))
try:
return WSGIController.__call__(self, environ, start_response)
finally:
meta.Session.remove()
-
+
+__all__ = ['c', 'h', 'render', 'render_response', 'validate',
+ 'model', 'meta', '_', 'ungettext', 'N_', 'BaseController']
View
7 bluechips/lib/helpers.py
@@ -3,4 +3,9 @@
Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to both as 'h'.
"""
-from webhelpers import *
+from routes import url_for, redirect_to
+from webhelpers.html import escape, literal, url_escape
+from webhelpers.html.tags import *
+
+def bluechips():
+ return '<span class="bluechips">BlueChips</span>'
Please sign in to comment.
Something went wrong with that request. Please try again.