def __init__(self): if (config.logfile_name): if (config.logfile_append): flag = 'a' else: flag = 'w' self.logFile = open(config.logfile_name, flag) self.dbHandler = database.DatabaseWrapper( self, config.db_host, config.db_user, config.db_passwd, config.db_name, config.db_engine, config.db_charset) self.sessionHandler = session.SessionHandler(self) self.userHandler = session.users.UserHandler(self) self.matchHandler = game.match.MatchHandler(self)
def __init__(self): if (config.logfile_name): if (config.logfile_append): flag = 'a' else: flag = 'w' self.logFile = open(config.logfile_name, flag) self.log("Initializing...") self.dbHandler = database.DatabaseWrapper( self, config.db_host, config.db_user, config.db_passwd, config.db_name, config.db_engine, config.db_charset) self.sessionHandler = session.SessionHandler(self) self.userHandler = session.users.UserHandler(self) self.matchHandler = game.match.MatchHandler(self) self.steamHandler = steam.SteamHandler(self) self.log("Started successfully")
''' pwhash = hashlib.sha224(password) pwhash.update(settings.SECRET_KEY) return pwhash.hexdigest() def filter_keys(src, blacklist): ''' filter_keys Helper function, removes the (key, value) pairs for keys in the blacklist list, returns filtered dictionary. ''' for key in blacklist: if key in src: del src[key] return src # Webapp initialization import session from .decorators import RPGFlask # RPGFlask is in decorators and is just an extended version of flask.Flask app = RPGFlask(__name__) app.session_interface = session.SessionHandler() app.jinja_env.line_statement_prefix = '%' app.debug = settings.DEBUG app.__version__ = __version__ # This just imports all of the webapps modules (defined in __all__) map(lambda module: import_module("." + module, __name__), __all__)
if _user.is_null: session.SessionHandler.inst.deluid(key) return _user def set_user(self, _user): key = session.SessionHandler.inst.setuid(_user.id) self.set_secure_cookie(RequestHandler.KEYNAME, str(key)) class MainHandler(RequestHandler): def get(self): _user = self.get_user() self.write(loader.load("index.html").generate(user=_user)) application = tornado.web.Application([ (r"/", MainHandler), (r'/static/(.*)', tornado.web.StaticFileHandler, { 'path': "./static/" }), ], cookie_secret=config.secure_cookie) if __name__ == "__main__": application.listen(8888) user.UserHandler() session.SessionHandler() tornado.ioloop.IOLoop.current().start()
async def init_webserver(app, loop): connect(host=WEBSERVER.config.MONGO_URI) session.SessionHandler(WEBSERVER)
async def init_webserver(*_): """Initialisatie webserver and sessions""" connect(host=WEBSERVER.config.MONGO_URI) session.SessionHandler(WEBSERVER)