def __init__(self, port, address, api_dir, debug, api_data_filename):

        self.pool = futures.ThreadPoolExecutor(2)
        self.api_settings_class = api_settings.ApiSettings

        supported_formats = "|".join(
            map(lambda x: ".%s" % x, SUPPORTED_FORMATS.keys()))
        handlers_list = [
            (r"/__manage/resource/(.*)", handlers.ResourceMethodHandler),
            (r"/__manage/rpc/(.*)", handlers.RPCMethodHandler),
            (r"/__manage/logs", handlers.ResourcesLogsHandler),
            (r"/__manage/create/rpc", handlers.CreateRPCMethodHandler),
            (r"/__manage/create", handlers.CreateResourceMethodHandler),
            (r"/__manage/login", handlers.LoginHandler),
            (r"/__manage/logout", handlers.LogoutHandler),
            (r"/__manage/settings", handlers.SettingsHandler),
            (r"/__manage/todo", handlers.TodoHandler),
            (r"/__manage", handlers.ListResourcesHandler),
            (r"/%s" % handlers.RPCHandler.PATH, handlers.RPCHandler),
            (r"/(.*)(%s)" % supported_formats, handlers.MainHandler),
            (r"/(.*)", handlers.MainHandler),
        ]
        settings = dict(
            debug=debug,
            port=port,
            address=address,
            dir=api_dir,
            api_data_filename=api_data_filename,
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            static_url_prefix="/__static/",
            login_url="/__manage/login",
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
        )
        super(Application, self).__init__(handlers_list, **settings)
    def __init__(self,
                 port,
                 address,
                 api_dir,
                 debug,
                 api_data_filename,
                 custom_provider=None):

        self.pool = futures.ThreadPoolExecutor(2)
        self.api_settings_class = api_settings.ApiSettings
        self.custom_provider = None

        if custom_provider is not None:
            provider_path = os.path.abspath(custom_provider)
            print(provider_path)
            module = imp.load_source('custom_provider', provider_path)
            if hasattr(module, 'provider'):
                self.custom_provider = module.provider

        supported_formats = "|".join(
            map(lambda x: ".%s" % x, SUPPORTED_FORMATS.keys()))
        handlers_list = [
            (r"/__manage/resource/(.*)", handlers.ResourceMethodHandler),
            (r"/__manage/rpc/(.*)", handlers.RPCMethodHandler),
            (r"/__manage/logs", handlers.ResourcesLogsHandler),
            (r"/__manage/create/rpc", handlers.CreateRPCMethodHandler),
            (r"/__manage/create", handlers.CreateResourceMethodHandler),
            (r"/__manage/login", handlers.LoginHandler),
            (r"/__manage/logout", handlers.LogoutHandler),
            (r"/__manage/settings", handlers.SettingsHandler),
            (r"/__manage/todo", handlers.TodoHandler),
            (r"/__manage", handlers.ListResourcesHandler),
            (r"/%s" % handlers.RPCHandler.PATH, handlers.RPCHandler),
            (r"/(.*)(%s)" % supported_formats, handlers.MainHandler),
            (r"/(.*)", handlers.MainHandler),
        ]
        settings = dict(
            debug=debug,
            port=port,
            address=address,
            dir=api_dir,
            api_data_filename=api_data_filename,
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            static_url_prefix="/__static/",
            login_url="/__manage/login",
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
        )
        super(Application, self).__init__(handlers_list, **settings)
Exemple #3
0
    def get(self):
        method_name = self.get_argument("method_name", "")

        method_file = RPCMethod(
            os.path.join(self.api_dir, RPCHandler.PATH), method_name)
        method_file.load()
        method_file.load_description()

        category = self.api_data.get_rpc_category(method_name)

        self.render(
            "create_resource.html",
            protocol="rpc", category=category, method_file=method_file,
            SUPPORTED_FORMATS=SUPPORTED_FORMATS.keys(),
            jsonrpc=jsonrpc_available)
    def get(self, flash_messages=None):
        url_path = self.get_argument("url_path", "")
        method = self.get_argument("method", None)

        method_file = ResourceMethod(
            self.api_dir, url_path, method)
        method_file.load_responses()
        method_file.load_description()

        if method is None:
            category = ""
        else:
            category = self.api_data.get_category(method_file.id)

        self.render(
            "create_resource.html",
            protocol="rest", category=category, method_file=method_file,
            SUPPORTED_FORMATS=SUPPORTED_FORMATS.keys(),
            jsonrpc=jsonrpc_available,
            flash_messages=flash_messages)
Exemple #5
0
    def get(self, flash_messages=None):
        url_path = self.get_argument("url_path", "")
        method = self.get_argument("method", None)

        method_file = ResourceMethod(
            self.api_dir, url_path, method)
        method_file.load_responses()
        method_file.load_description()

        if method is None:
            category = ""
        else:
            category = self.api_data.get_category(method_file.id)

        self.render(
            "create_resource.html",
            protocol="rest", category=category, method_file=method_file,
            SUPPORTED_FORMATS=SUPPORTED_FORMATS.keys(),
            jsonrpc=jsonrpc_available,
            flash_messages=flash_messages)