Beispiel #1
0
    def post(self):
        # check xsrf cookie
        self.check_xsrf_cookie()

        # get data from request body
        data = tornado.escape.json_decode(self.request.body)

        if data["protocol"] == "rest":
            method, url_path = data["id"].split("-")
            method_file = ResourceMethod(self.api_dir, url_path, method)
        elif data["protocol"] == "rpc":
            method_file = RPCMethod(
                os.path.join(self.api_dir, RPCHandler.PATH), data["id"])

        # load description
        method_file.load_description()

        # set todo
        value = " %s" % data["value"].strip()
        todo = "%s%s" % ("[x]" if data["checked"] else "[ ]", value)
        method_file.description = re.sub(
            r"\[( |x)\]%s" % re.escape(value), todo, method_file.description)

        # save description
        method_file.save_description()

        self.set_header("Content-Type", "application/json")
        self.write("OK")
Beispiel #2
0
    def post(self):
        # check xsrf cookie
        self.check_xsrf_cookie()

        # get data from request body
        data = tornado.escape.json_decode(self.request.body)

        if data["protocol"] == "rest":
            method, url_path = data["id"].split("-")
            method_file = ResourceMethod(self.api_dir, url_path, method)
        elif data["protocol"] == "rpc":
            method_file = RPCMethod(
                os.path.join(self.api_dir, RPCHandler.PATH), data["id"])

        # load description
        method_file.load_description()

        # set todo
        value = " %s" % data["value"].strip()
        todo = "%s%s" % ("[x]" if data["checked"] else "[ ]", value)
        method_file.description = re.sub(
            r"\[( |x)\]%s" % re.escape(value), todo, method_file.description)

        # save description
        method_file.save_description()

        self.set_header("Content-Type", "application/json")
        self.write("OK")
Beispiel #3
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)
Beispiel #4
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)