# Path: turbo/app.py
# class Mixin(tornado.web.RequestHandler):
# class BaseBaseHandler(Mixin):
# class BaseHandler(BaseBaseHandler):
# class ErrorHandler(tornado.web.RequestHandler):
#     def to_objectid(objid):
#     def to_int(value):
#     def to_float(value):
#     def to_bool(value):
#     def to_str(v):
#     def utf8(v):
#     def encode_http_params(**kw):
#     def json_encode(data, **kwargs):
#     def json_decode(data, **kwargs):
#     def is_ajax(self):
#     def initialize(self):
#     def session(self):
#     def get_template_namespace(self):
#     def render_string(self, template_name, **kwargs):
#     def sort_by(self, sort):
#     def get_context(self):
#     def wo_json(self, data):
#     def ri_json(self, data):
#     def parameter(self):
#         def filter_parameter(key, tp, default=None):
#     def head(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def post(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def patch(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def options(self, *args, **kwargs):
#     def _method_call(self, method, *args, **kwargs):
#     def init_resp(code=0, msg=None):
#     def wo_resp(self, resp):
#     def HEAD(self, *args, **kwargs):
#     def GET(self, *args, **kwargs):
#     def POST(self, *args, **kwargs):
#     def DELETE(self, *args, **kwargs):
#     def PATCH(self, *args, **kwargs):
#     def PUT(self, *args, **kwargs):
#     def OPTIONS(self, *args, **kwargs):
#     def route(self, route, *args, **kwargs):
#     def on_finish(self):
#     def _processor(self):
#     def initialize(self, status_code):
#     def prepare(self):
# def start(port=8888):
# 
# Path: turbo/register.py
# def _install_app(package_space):
# def register_app(app_name, app_setting, web_application_setting, mainfile, package_space):
# def register_url(url, handler, name=None, kwargs=None):
# def register_group_urls(prefix, urls):
# 
# 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/template.py
# def turbo_jinja2(func):
#     _jinja2_env = Jinja2Environment(loader=FileSystemLoader(app_config.web_application_setting[
#                                     'template_path']), auto_reload=app_config.web_application_setting['debug'])
# 
#     @functools.wraps(func)
#     def wrapper(self, template_name, **kwargs):
#         template = _jinja2_env.get_template(
#             ('%s%s') % (self.template_path, template_name))
#         return template.render(handler=self, request=self.request, xsrf_form_html=self.xsrf_form_html(),
#                                context=self.get_context(), **kwargs)
# 
#     return wrapper


import multiprocessing
import os
import shutil
import signal
import socket
import tempfile
import time
import requests
from turbo import app
from turbo import register
from turbo.conf import app_config
from turbo.template import turbo_jinja2
from util import unittest

app_config.app_name = 'app_test'
app_config.app_setting['template'] = 'jinja2'
tmp_source = tempfile.mkdtemp()
TEMPLATE_PATH = os.path.join(tmp_source, "templates")
app_config.web_application_setting = {
    'xsrf_cookies': False,
    'cookie_secret': 'adasfd',
    'template_path': TEMPLATE_PATH,
    'debug': True,
}


class HomeHandler(app.BaseHandler):

    def get(self):
        self.render('index.html')

    @turbo_jinja2
    def render_string(self, *args, **kwargs):
        pass


PID = None
URL = None


def run_server(port):
    register.register_url('/', HomeHandler)
    register.register_url('', HomeHandler)

# Path: turbo/app.py
# class Mixin(tornado.web.RequestHandler):
# class BaseBaseHandler(Mixin):
# class BaseHandler(BaseBaseHandler):
# class ErrorHandler(tornado.web.RequestHandler):
#     def to_objectid(objid):
#     def to_int(value):
#     def to_float(value):
#     def to_bool(value):
#     def to_str(v):
#     def utf8(v):
#     def encode_http_params(**kw):
#     def json_encode(data, **kwargs):
#     def json_decode(data, **kwargs):
#     def is_ajax(self):
#     def initialize(self):
#     def session(self):
#     def get_template_namespace(self):
#     def render_string(self, template_name, **kwargs):
#     def sort_by(self, sort):
#     def get_context(self):
#     def wo_json(self, data):
#     def ri_json(self, data):
#     def parameter(self):
#         def filter_parameter(key, tp, default=None):
#     def head(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def post(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def patch(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def options(self, *args, **kwargs):
#     def _method_call(self, method, *args, **kwargs):
#     def init_resp(code=0, msg=None):
#     def wo_resp(self, resp):
#     def HEAD(self, *args, **kwargs):
#     def GET(self, *args, **kwargs):
#     def POST(self, *args, **kwargs):
#     def DELETE(self, *args, **kwargs):
#     def PATCH(self, *args, **kwargs):
#     def PUT(self, *args, **kwargs):
#     def OPTIONS(self, *args, **kwargs):
#     def route(self, route, *args, **kwargs):
#     def on_finish(self):
#     def _processor(self):
#     def initialize(self, status_code):
#     def prepare(self):
# def start(port=8888):
# 
# Path: turbo/register.py
# def _install_app(package_space):
# def register_app(app_name, app_setting, web_application_setting, mainfile, package_space):
# def register_url(url, handler, name=None, kwargs=None):
# def register_group_urls(prefix, urls):
# 
# 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/template.py
# def turbo_jinja2(func):
#     _jinja2_env = Jinja2Environment(loader=FileSystemLoader(app_config.web_application_setting[
#                                     'template_path']), auto_reload=app_config.web_application_setting['debug'])
# 
#     @functools.wraps(func)
#     def wrapper(self, template_name, **kwargs):
#         template = _jinja2_env.get_template(
#             ('%s%s') % (self.template_path, template_name))
#         return template.render(handler=self, request=self.request, xsrf_form_html=self.xsrf_form_html(),
#                                context=self.get_context(), **kwargs)
# 
#     return wrapper


# Path: tests/jinja2_test.py
import multiprocessing
import os
import shutil
import signal
import socket
import tempfile
import time
import requests
from turbo import app
from turbo import register
from turbo.conf import app_config
from turbo.template import turbo_jinja2
from util import unittest


app_config.app_name = 'app_test'
app_config.app_setting['template'] = 'jinja2'
tmp_source = tempfile.mkdtemp()
TEMPLATE_PATH = os.path.join(tmp_source, "templates")
app_config.web_application_setting = {
    'xsrf_cookies': False,
    'cookie_secret': 'adasfd',
    'template_path': TEMPLATE_PATH,
    'debug': True,
}


class HomeHandler(app.BaseHandler):

    def get(self):
        self.render('index.html')

    @turbo_jinja2
    def render_string(self, *args, **kwargs):
        pass


PID = None
URL = None


def run_server(port):
    register.register_url('/', HomeHandler)
    register.register_url('', HomeHandler)

    app.start(port)