Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 25 lines (20 sloc) 0.712 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# -*- coding: utf-8 -*-
# AUTHOR: Zeray Rice <fanzeyi1994@gmail.com>
# FILE: lang.py
# CREATED: 02:44:51 08/03/2012
# MODIFIED: 02:54:55 08/03/2012
# DESCRIPTION: Set language handler

from tornado.web import HTTPError

from config import accept_lang

from judge.base import BaseHandler

class SetLanguageHandler(BaseHandler):
    ''' `/lang/(.*)` - set language. '''
    def get(self, lang):
        if lang not in accept_lang.keys():
            raise HTTPError(404)
        self.set_cookie('LANG', accept_lang[lang])
        if self.request.headers.has_key('Referer'):
            self.redirect(self.request.headers['Referer'])
            return
        self.redirect('/')

__all__ = ["SetLanguageHandler"]
Something went wrong with that request. Please try again.