<s> """<STR_LIT>""" <EOL> from pylons import c , cache , config , g , request , response , session <EOL> from pylons . controllers . util import abort , etag_cache , redirect_to <EOL> from pylons . i18n import _ , ungettext , N_ <EOL> from pylons . controllers import WSGIController <EOL> from pylons . templating import render_genshi as render <EOL> from pylons import config <EOL> import shakespeare . lib . helpers as h <EOL> import shakespeare . model as model <EOL> import shakespeare <EOL> class BaseController ( WSGIController ) : <EOL> def __call__ ( self , environ , start_response ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return WSGIController . __call__ ( self , environ , start_response ) <EOL> finally : <EOL> model . Session . remove ( ) <EOL> def _set_user ( self ) : <EOL> c . username = request . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) . decode ( '<STR_LIT:utf8>' ) <EOL> c . user = None <EOL> if c . username : <EOL> c . user = model . User . query . filter_by ( openid = c . username ) . first ( ) <EOL> if not c . user and c . username : <EOL> c . user = model . User ( openid = c . username ) <EOL> model . Session . commit ( ) <EOL> c . remote_addr = request . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if not c . remote_addr : <EOL> c . remote_addr = request . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if c . user : <EOL> c . author = c . user . name <EOL> else : <EOL> c . author = c . remote_addr <EOL> c . author = unicode ( c . author ) <EOL> def __before__ ( self , action , ** params ) : <EOL> c . site_title = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> c . __version__ = shakespeare . __version__ <EOL> c . word_of_the_day_enable = bool ( config . get ( '<STR_LIT>' , <EOL> False ) ) <EOL> if c . word_of_the_day_enable : <EOL> c . word_of_the_day = model . Word . word_of_the_day ( ) <EOL> c . notification = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _set_user ( ) </s>
