<s> import datetime <EOL> from projectname . lib . base import * <EOL> try : <EOL> import sqlalchemy as sa <EOL> from projectname . model . meta import Session , Base <EOL> from projectname . model import Foo <EOL> SQLAtesting = True <EOL> except : <EOL> SQLAtesting = False <EOL> import projectname . lib . helpers as h <EOL> from pylons import request , response , session <EOL> from pylons import tmpl_context as c <EOL> from pylons import app_globals <EOL> from pylons . decorators import rest <EOL> from pylons . i18n import _ , get_lang , set_lang , LanguageError <EOL> from pylons . templating import render_mako , render_genshi , render_jinja2 <EOL> from pylons . controllers . util import abort , redirect <EOL> class SampleController ( BaseController ) : <EOL> def index ( self ) : <EOL> return '<STR_LIT>' <EOL> def testsqlalchemy ( self ) : <EOL> if SQLAtesting : <EOL> c . foos = Session . query ( Foo ) . all ( ) <EOL> return render_mako ( '<STR_LIT>' ) <EOL> pass <EOL> def set_lang ( self ) : <EOL> return self . _set_lang ( _ ) <EOL> def set_lang_pylonscontext ( self , pylons ) : <EOL> return self . _set_lang ( lambda * args : pylons . translator . ugettext ( * args ) ) <EOL> def _set_lang ( self , gettext ) : <EOL> lang = request . GET [ '<STR_LIT>' ] <EOL> try : <EOL> set_lang ( lang ) <EOL> except ( LanguageError , IOError ) , e : <EOL> resp_unicode = gettext ( '<STR_LIT>' ) % { '<STR_LIT>' : lang } <EOL> else : <EOL> session [ '<STR_LIT>' ] = lang <EOL> session . save ( ) <EOL> resp_unicode = gettext ( '<STR_LIT>' ) % { '<STR_LIT>' : lang } <EOL> return resp_unicode <EOL> def i18n_index ( self ) : <EOL> locale_list = request . languages <EOL> set_lang ( request . languages ) <EOL> return unicode ( _ ( '<STR_LIT>' ) ) <EOL> def no_lang ( self ) : <EOL> set_lang ( None ) <EOL> response . write ( _ ( '<STR_LIT>' ) ) <EOL> set_lang ( [ ] ) <EOL> response . write ( _ ( '<STR_LIT>' ) ) <EOL> return '<STR_LIT>' </s>
