<commit_before>'''
Created on Mar 15, 2012

@author: moloch
'''

from models import User
from libs.SecurityDecorators import *
from libs.Session import SessionManager
from tornado.web import RequestHandler #@UnresolvedImport

class UserBaseHandler(RequestHandler):
    ''' User handlers extend this class '''
    
    def initialize(self, dbsession):
        self.dbsession = dbsession
        self.session_manager = SessionManager.Instance()
        self.session = self.session_manager.get_session(self.get_secure_cookie('auth'), self.request.remote_ip)
    
    def get_current_user(self):
        if self.session != None:
            return User.by_user_name(self.session.data['user_name'])
        return None

class AdminBaseHandler(RequestHandler):
    ''' Admin handlers extend this class '''
    
    def initialize(self, dbsession):
        self.dbsession = dbsession
        self.get_functions = {
            'challenge':self.get_challenge,
            'action': self.get_action, 
            'team': self.get_team, 
            'user': self.get_user,
            'box': self.get_box, 
            'crackme': self.get_crack_me, 
            'se': self.get_se
        }
        self.post_functions = {
            'challenge':self.post_challenge,
            'action': self.post_action, 
            'team': self.post_team,
            'user': self.post_user,<commit_msg>Updated base hanlder to use custom 404<commit_after>'''
Created on Mar 15, 2012

@author: moloch
'''

import logging

from models import User
from libs.SecurityDecorators import *
from libs.Session import SessionManager
from tornado.web import RequestHandler #@UnresolvedImport

class UserBaseHandler(RequestHandler):
    ''' User handlers extend this class '''
    
    def initialize(self, dbsession):
        self.dbsession = dbsession
        self.session_manager = SessionManager.Instance()
        self.session = self.session_manager.get_session(self.get_secure_cookie('auth'), self.request.remote_ip)
    
    def get_current_user(self):
        if self.session != None:
            return User.by_user_name(self.session.data['user_name'])
        return None

    def write_error(code, **kwargs):
        logging.info("HTTP Error "+str(code)+": Client at %s" % self.request.remote_ip)
        if code == 404 or code == 500:
            self.redirect("/404")
        else:
            self.write("wat")
            self.finish()

class AdminBaseHandler(RequestHandler):
    ''' Admin handlers extend this class '''
    
    def initialize(self, dbsession):
        self.dbsession = dbsession
        self.get_functions = {
            'challenge':self.get_challenge,
            'action': self.get_action, 
            'team': self.get_team, 
            'user': self.get_user,
            'box': self.get_box, 
            'crackme': self.get_crack_me, 
            'se': self.get_se
        }
        self.post_functions = {
            'challenge':self.post_challenge,
            'action': self.post_action, 
            'team': self.post_team,
            'user': self.post_user,
{'fraction_non_alphanumeric': 0.107421875, 'fraction_numerical': 0.0078125, 'mean_word_length': 2.4801812004530013, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1273940', 'n_tokens_mistral': 927, 'n_tokens_neox': 872, 'n_words': 195}