# Path: turbo/util.py
# PY3 = sys.version_info >= (3,)
# _UTF8_TYPES = (bytes, type(None))
# _BASESTRING_TYPES = (basestring_type, type(None))
# def to_list_str(value, encode=None):
# def to_dict_str(origin_value, encode=None):
# def default_encode(v):
# def to_str(v, encode=None):
# def format_time(dt):
# def to_objectid(objid):
# def json_encode(data, **kwargs):
# def json_decode(data, **kwargs):
# def to_int(value, default=None):
# def to_float(value, default=None):
# def to_datetime(t, micro=False):
# def to_time(t, micro=False):
#     def __init__(self, module):
#     def __getattr__(self, name):
# def get_base_dir(currfile, dir_level_num=3):
# def join_sys_path(currfile, dir_level_num=3):
# def import_object(name, package_space=None):
# def camel_to_underscore(name):
# def remove_folder(path, foldername):
# def remove_file(path, filename):
# def remove_extension(path, extension):
# def build_index(model_list):
# def utf8(value):
# def to_basestring(value):
# def get_func_name(func):
# class Escape(object):
# 
# Path: turbo/conf.py
# class ObjectDict(dict):
# class AppConfig(object):
#     def __getattr__(self, name):
#         def __setattr__(self, name, value):
#     def __init__(self):
#     def log_level(self):
# 
# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):
# 
# Path: turbo/session.py
# class Session(object):
# 
#     __slots__ = ['store', 'handler', 'app', '_data', '_dirty', '_config',
#                  '_initializer', 'session_id', '_session_object', '_session_name']
# 
#     def __init__(self, app, handler, store, initializer, session_config=None, session_object=None):
#         self.handler = handler
#         self.app = app
#         self.store = store or DiskStore(app_config.store_config.diskpath)
# 
#         self._config = deepcopy(app_config.session_config)
#         if session_config:
#             self._config.update(session_config)
# 
#         self._session_name = self._config.name
# 
#         self._session_object = (session_object or CookieObject)(
#             app, handler, self.store, self._config)
# 
#         self._data = ObjectDict()
#         self._initializer = initializer
# 
#         self.session_id = None
# 
#         self._dirty = False
#         self._processor()
# 
#     def __getitem__(self, name):
#         if name not in self._data:
#             session_log.error('%s key not exist in %s session' %
#                               (name, self.session_id))
# 
#         return self._data.get(name, None)
# 
#     def __setitem__(self, name, value):
#         self._data[name] = value
#         self._dirty = True
# 
#     def __delitem__(self, name):
#         del self._data[name]
#         self._dirty = True
# 
#     def __contains__(self, name):
#         return name in self._data
# 
#     def __len__(self):
#         return len(self._data)
# 
#     def __getattr__(self, name):
#         return getattr(self._data, name)
# 
#     def __setattr__(self, name, value):
#         if name in self.__slots__:
#             super(Session, self).__setattr__(name, value)
#         else:
#             self._dirty = True
#             setattr(self._data, name, value)
# 
#     def __delattr__(self, name):
#         delattr(self._data, name)
#         self._dirty = True
# 
#     def __iter__(self):
#         for key in self._data:
#             yield key
# 
#     def __repr__(self):
#         return str(self._data)
# 
#     def _processor(self):
#         """Application processor to setup session for every request"""
#         self.store.cleanup(self._config.timeout)
#         self._load()
# 
#     def _load(self):
#         """Load the session from the store, by the id from cookie"""
# 
#         self.session_id = self._session_object.get_session_id()
# 
#         # protection against session_id tampering
#         if self.session_id and not self._valid_session_id(self.session_id):
#             self.session_id = None
# 
#         if self.session_id:
#             d = self.store[self.session_id]
#             if isinstance(d, dict) and d:
#                 self.update(d)
# 
#         if not self.session_id:
#             self.session_id = self._session_object.generate_session_id()
# 
#         if not self._data:
#             if self._initializer and isinstance(self._initializer, dict):
#                 self.update(deepcopy(self._initializer))
# 
#         self._session_object.set_session_id(self.session_id)
# 
#     def save(self):
#         if self._dirty:
#             self.store[self.session_id] = self._data
# 
#     def _valid_session_id(self, session_id):
#         return True
# 
#     def kill(self):
#         """Kill the session, make it no longer available"""
#         del self.store[self.session_id]
# 
#     def clear(self):
#         del self.store[self.session_id]


import io
import tornado.escape
import tornado.httpserver
import tornado.ioloop
import tornado.web
import turbo.httputil as _ht
from bson.objectid import ObjectId
from pymongo import ASCENDING, DESCENDING
from tornado.util import ObjectDict
from turbo.core.exceptions import ResponseMsg
from turbo.util import escape as _es, PY3, basestring_type
from turbo.conf import app_config
from turbo.log import app_log
from turbo.session import Session
# -*- coding:utf-8 -*-
from __future__ import absolute_import, print_function






if PY3:
    file_types = (io.IOBase,)
else:

# Path: turbo/util.py
# PY3 = sys.version_info >= (3,)
# _UTF8_TYPES = (bytes, type(None))
# _BASESTRING_TYPES = (basestring_type, type(None))
# def to_list_str(value, encode=None):
# def to_dict_str(origin_value, encode=None):
# def default_encode(v):
# def to_str(v, encode=None):
# def format_time(dt):
# def to_objectid(objid):
# def json_encode(data, **kwargs):
# def json_decode(data, **kwargs):
# def to_int(value, default=None):
# def to_float(value, default=None):
# def to_datetime(t, micro=False):
# def to_time(t, micro=False):
#     def __init__(self, module):
#     def __getattr__(self, name):
# def get_base_dir(currfile, dir_level_num=3):
# def join_sys_path(currfile, dir_level_num=3):
# def import_object(name, package_space=None):
# def camel_to_underscore(name):
# def remove_folder(path, foldername):
# def remove_file(path, filename):
# def remove_extension(path, extension):
# def build_index(model_list):
# def utf8(value):
# def to_basestring(value):
# def get_func_name(func):
# class Escape(object):
# 
# Path: turbo/conf.py
# class ObjectDict(dict):
# class AppConfig(object):
#     def __getattr__(self, name):
#         def __setattr__(self, name, value):
#     def __init__(self):
#     def log_level(self):
# 
# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):
# 
# Path: turbo/session.py
# class Session(object):
# 
#     __slots__ = ['store', 'handler', 'app', '_data', '_dirty', '_config',
#                  '_initializer', 'session_id', '_session_object', '_session_name']
# 
#     def __init__(self, app, handler, store, initializer, session_config=None, session_object=None):
#         self.handler = handler
#         self.app = app
#         self.store = store or DiskStore(app_config.store_config.diskpath)
# 
#         self._config = deepcopy(app_config.session_config)
#         if session_config:
#             self._config.update(session_config)
# 
#         self._session_name = self._config.name
# 
#         self._session_object = (session_object or CookieObject)(
#             app, handler, self.store, self._config)
# 
#         self._data = ObjectDict()
#         self._initializer = initializer
# 
#         self.session_id = None
# 
#         self._dirty = False
#         self._processor()
# 
#     def __getitem__(self, name):
#         if name not in self._data:
#             session_log.error('%s key not exist in %s session' %
#                               (name, self.session_id))
# 
#         return self._data.get(name, None)
# 
#     def __setitem__(self, name, value):
#         self._data[name] = value
#         self._dirty = True
# 
#     def __delitem__(self, name):
#         del self._data[name]
#         self._dirty = True
# 
#     def __contains__(self, name):
#         return name in self._data
# 
#     def __len__(self):
#         return len(self._data)
# 
#     def __getattr__(self, name):
#         return getattr(self._data, name)
# 
#     def __setattr__(self, name, value):
#         if name in self.__slots__:
#             super(Session, self).__setattr__(name, value)
#         else:
#             self._dirty = True
#             setattr(self._data, name, value)
# 
#     def __delattr__(self, name):
#         delattr(self._data, name)
#         self._dirty = True
# 
#     def __iter__(self):
#         for key in self._data:
#             yield key
# 
#     def __repr__(self):
#         return str(self._data)
# 
#     def _processor(self):
#         """Application processor to setup session for every request"""
#         self.store.cleanup(self._config.timeout)
#         self._load()
# 
#     def _load(self):
#         """Load the session from the store, by the id from cookie"""
# 
#         self.session_id = self._session_object.get_session_id()
# 
#         # protection against session_id tampering
#         if self.session_id and not self._valid_session_id(self.session_id):
#             self.session_id = None
# 
#         if self.session_id:
#             d = self.store[self.session_id]
#             if isinstance(d, dict) and d:
#                 self.update(d)
# 
#         if not self.session_id:
#             self.session_id = self._session_object.generate_session_id()
# 
#         if not self._data:
#             if self._initializer and isinstance(self._initializer, dict):
#                 self.update(deepcopy(self._initializer))
# 
#         self._session_object.set_session_id(self.session_id)
# 
#     def save(self):
#         if self._dirty:
#             self.store[self.session_id] = self._data
# 
#     def _valid_session_id(self, session_id):
#         return True
# 
#     def kill(self):
#         """Kill the session, make it no longer available"""
#         del self.store[self.session_id]
# 
#     def clear(self):
#         del self.store[self.session_id]


# Path: turbo/app.py
import io
import tornado.escape
import tornado.httpserver
import tornado.ioloop
import tornado.web
import turbo.httputil as _ht
from bson.objectid import ObjectId
from pymongo import ASCENDING, DESCENDING
from tornado.util import ObjectDict
from turbo.core.exceptions import ResponseMsg
from turbo.util import escape as _es, PY3, basestring_type
from turbo.conf import app_config
from turbo.log import app_log
from turbo.session import Session

# -*- coding:utf-8 -*-
from __future__ import absolute_import, print_function






if PY3:
    file_types = (io.IOBase,)
else:

    file_types = file, io.IOBase