Created
February 9, 2012 14:11
-
-
Save ralphbean/1780206 to your computer and use it in GitHub Desktop.
tg2app/lib/base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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