def info(handler): session = get(handler) if session is None: return None id_ = session.get('uid', None) if id_ is None: return None host = config.mysql_host user = config.mysql_user password = config.mysql_password database = config.mysql_database con = tool.connect_mysql(host = host, user = user, password = password, database = database) if con is None: return None connector = tool.Connector(con) db_result = connector.select('u_user', '`id` = %s' % id_) connector.close() if len(db_result) == 0: return None return db_result[0]
def MysqlConnector(): if not globals().has_key('mysql_host'): LoadMysqlConfig() if not globals().has_key('mysql_user'): LoadMysqlConfig() if not globals().has_key('mysql_password'): LoadMysqlConfig() if not globals().has_key('mysql_database'): LoadMysqlConfig() host = mysql_host user = mysql_user password = mysql_password database = mysql_database con = tool.connect_mysql( host = host, user = user, password = password, database = database ) if con is None: return None connector = tool.Connector(con) return connector