Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created February 9, 2012 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphbean/1780206 to your computer and use it in GitHub Desktop.
Save ralphbean/1780206 to your computer and use it in GitHub Desktop.
tg2app/lib/base.py
# -*- coding: utf-8 -*-
"""The base Controller API."""
from tg import config
from tg import TGController, tmpl_context
from tg.render import render
from tg import request
from tg.i18n import ugettext as _, ungettext
from paste.deploy.converters import asbool
import tg2app.model as model
__all__ = ['BaseController']
class BaseController(TGController):
"""
Base class for the controllers in the application.
Your web application should have one of these. The root of
your application is used to compute URLs used by your app.
"""
def __call__(self, environ, start_response):
"""Invoke the Controller"""
# TGController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
# For this, you'll need to add in_production = True and in_production =
# False to your `development.ini` and `production.ini` config files.
tmpl_context.in_production = asbool(config.get('in_production'))
return TGController.__call__(self, environ, start_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment