# Path: m2core/common/options.py
# class M2OptionParser(OptionParser):
#     def parse_environment(self, final=True):
# 
# Path: m2core/m2core.py
# class M2Core:
#     def requires_permission(handler_method_func):
#         def decorated(handler_instance, *args, **kwargs):
#     def user_can(handler_method):
#         def decorated(handler_instance, *args, **kwargs):
#     def tryex(*errors):
#         def decorator(func):
#             def new_func(handler, *args, **kwargs):
#     def __recreate_db(self):
#     def __init__(self):
#     def __make_app(self):
#     def route(self, human_route: str=None, handler_cls: Type[RequestHandler]=None, rule_group: str=None,
#               extra: dict=None, **kwargs):
#     def add_endpoint(self, human_route: str, handler_class: Type[RequestHandler], extra_params: dict = dict()):
#     def add_endpoint_method_permissions(self, human_route: str, method: str, permissions: list or None):
#     def add_endpoint_permissions(self, human_route: str, permissions: dict):
#     def add_redis_scheme(self, _redis_scheme: dict):
#     def thread_pool(self) -> ThreadPoolExecutor:
#     def db_engine(self) -> Engine:
#     def db_session(self) -> scoped_session:
#     def redis_session(self) -> redis.StrictRedis:
#     def redis_tables(self) -> dict:
#     def app(self) -> tornado.web.Application:
#     def __make_db_session(self):
#     def __make_thread_pool(self):
#     def __make_redis_session(self):
#     def add_callback(self, callback: callable, *args, **kwargs):
#     def extended(self, callback: callable):
#         def call_me_maybe(*args, **kwargs):
#     def add_custom_response_headers(self, headers: dict()):
#     def run(self):
#     def run_with_recreate(self):
#     def run_for_test(self) -> tornado.web.Application:
#     def add_test_user(self, at: str, user_id: int=None, permissions: set=None):
#     def get_test_user(self, at: str) -> dict:
# def sync_permissions():
# def dump_roles():


from m2core.common.options import options
from example.handlers import *
from m2core import M2Core, logger as core_logger
from tornado.gen import coroutine, sleep
import logging
        'Access-Control-Allow-Headers': 'Content-Type, X-Access-Token'
    })

    # ENDPOINTS
    human_route = r'/docs.js'
    m2core.add_endpoint(human_route, RestApiDocsHandler)
    m2core.add_endpoint_method_permissions(human_route, 'get', [])

    human_route = r'/admin/users/:{id:int}'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # you can add permissions like that
    m2core.add_endpoint_method_permissions(human_route, 'get', [options.default_permission, 'get user info'])
    m2core.add_endpoint_method_permissions(human_route, 'post', None)
    m2core.add_endpoint_method_permissions(human_route, 'put', [options.default_permission, 'modify user'])
    m2core.add_endpoint_method_permissions(human_route, 'delete', [options.default_permission, 'delete user'])

    human_route = r'/users'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # or like that
    m2core.add_endpoint_permissions(human_route, {
        'get': None,
        'post': [],
        'put': None,
        'delete': None,
    })

    human_route = r'/users/self'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # and that
    m2core.add_endpoint_permissions(human_route, {

# Path: m2core/common/options.py
# class M2OptionParser(OptionParser):
#     def parse_environment(self, final=True):
# 
# Path: m2core/m2core.py
# class M2Core:
#     def requires_permission(handler_method_func):
#         def decorated(handler_instance, *args, **kwargs):
#     def user_can(handler_method):
#         def decorated(handler_instance, *args, **kwargs):
#     def tryex(*errors):
#         def decorator(func):
#             def new_func(handler, *args, **kwargs):
#     def __recreate_db(self):
#     def __init__(self):
#     def __make_app(self):
#     def route(self, human_route: str=None, handler_cls: Type[RequestHandler]=None, rule_group: str=None,
#               extra: dict=None, **kwargs):
#     def add_endpoint(self, human_route: str, handler_class: Type[RequestHandler], extra_params: dict = dict()):
#     def add_endpoint_method_permissions(self, human_route: str, method: str, permissions: list or None):
#     def add_endpoint_permissions(self, human_route: str, permissions: dict):
#     def add_redis_scheme(self, _redis_scheme: dict):
#     def thread_pool(self) -> ThreadPoolExecutor:
#     def db_engine(self) -> Engine:
#     def db_session(self) -> scoped_session:
#     def redis_session(self) -> redis.StrictRedis:
#     def redis_tables(self) -> dict:
#     def app(self) -> tornado.web.Application:
#     def __make_db_session(self):
#     def __make_thread_pool(self):
#     def __make_redis_session(self):
#     def add_callback(self, callback: callable, *args, **kwargs):
#     def extended(self, callback: callable):
#         def call_me_maybe(*args, **kwargs):
#     def add_custom_response_headers(self, headers: dict()):
#     def run(self):
#     def run_with_recreate(self):
#     def run_for_test(self) -> tornado.web.Application:
#     def add_test_user(self, at: str, user_id: int=None, permissions: set=None):
#     def get_test_user(self, at: str) -> dict:
# def sync_permissions():
# def dump_roles():


# Path: example/old_run_me.py
from m2core.common.options import options
from example.handlers import *
from m2core import M2Core, logger as core_logger
from tornado.gen import coroutine, sleep
import logging

        'Access-Control-Allow-Headers': 'Content-Type, X-Access-Token'
    })

    # ENDPOINTS
    human_route = r'/docs.js'
    m2core.add_endpoint(human_route, RestApiDocsHandler)
    m2core.add_endpoint_method_permissions(human_route, 'get', [])

    human_route = r'/admin/users/:{id:int}'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # you can add permissions like that
    m2core.add_endpoint_method_permissions(human_route, 'get', [options.default_permission, 'get user info'])
    m2core.add_endpoint_method_permissions(human_route, 'post', None)
    m2core.add_endpoint_method_permissions(human_route, 'put', [options.default_permission, 'modify user'])
    m2core.add_endpoint_method_permissions(human_route, 'delete', [options.default_permission, 'delete user'])

    human_route = r'/users'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # or like that
    m2core.add_endpoint_permissions(human_route, {
        'get': None,
        'post': [],
        'put': None,
        'delete': None,
    })

    human_route = r'/users/self'
    m2core.add_endpoint(human_route, AdminUsersHandler)
    # and that
    m2core.add_endpoint_permissions(human_route, {

        'get': [options.default_permission, ],