def __init__(self): """ sets up db engine and connection pool.""" from wigi.conf.config import getConfiguration from sqlalchemy import create_engine from sqlalchemy.pool import QueuePool from sqlalchemy.orm import sessionmaker print "in dbmanager init" #get configuration data self.site_config = getConfiguration() #self.__connectionString = 'sqlite:///:memory:'; self.__connectionString = "%s%s:%s@%s/%s" % (self.site_config.get('database','driver'), self.site_config.get('database','username'), self.site_config.get('database','password'), self.site_config.get('database','host'),self.site_config.get('database','dbname')) self.engine = create_engine(self.__connectionString, echo=self.site_config.get('database','echo'), poolclass=QueuePool) #setup session self.Session = sessionmaker(bind=self.engine, expire_on_commit=False)
""" This class sets up the landing page for wigi. """ import tornado.web import tornado.auth import logging from wigi.Handlers.BaseHandler import BaseHandler from wigi.conf.config import getConfiguration #get configuration data site_config = getConfiguration() class MainHandler(BaseHandler,tornado.auth.FacebookGraphMixin): @tornado.web.asynchronous def get(self): if not self.current_user: self.render("index.html", login_status='false') else: print self.current_user self.facebook_request("/me", access_token=self.current_user["access_token"], callback=self.async_callback(self.__on_user_info_get)) def __on_user_info_get(self, userInfo): print userInfo #update user info print "Asdfasfasfas" print self.current_user self.current_user['name']=userInfo['name'] self.render("index.html", login_status='true')