]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/lib/base.py
Fix some typos in the model
[bluechips.git] / bluechips / lib / base.py
index d33cfc2034b901e29bfa09a2b895270045c538a8..f561cec419e048606ab4d0c4c3432d77d1356162 100644 (file)
@@ -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 @@ class BaseController(WSGIController):
         # 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'] == 'index':
+                environ['PATH_INFO'] += '/'
+                raise HTTPMovedPermanently(construct_url(environ))
         try:
             return WSGIController.__call__(self, environ, start_response)
         finally:
             meta.Session.remove()
-        
\ No newline at end of file
+
+__all__ = ['c', 'h', 'render', 'render_response', 'validate',
+           'model', 'meta', '_', 'ungettext', 'N_', 'BaseController']