"""The base Controller API

Provides the BaseController class for subclassing.
"""
from pylons.controllers import WSGIController
{{if template_engine in ('genshi', 'jinja2', 'mako')}}
from pylons.templating import render_{{template_engine}} as render
{{endif}}

from {{package}} import model




class BaseController(WSGIController):
    
    def __call__(self, environ, start_response):
        # Insert any code to be run per request here. The Routes match
        # is under environ['pylons.routes_dict'] should you want to check
        # the action or route vars here
        # if not environ['PATH_INFO'].endswith('/'):
        #     environ['PATH_INFO'] += '/'
        #     url = construct_url(environ)
        #     raise HTTPMovedPermanently(url)
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            model.Session.remove()
    
