예제 #1
0
 def finalize(self, response):
     self.write(response)
     url_schema = build_schema_url(self.query_params, propagate_params=True)
     self.set_header("Content-Type", content_type_profile(url_schema))
     # FIXME: handle cache policy uniformly
     self.set_header("Cache-control", "private")
     self.set_header("max-age", "0")
예제 #2
0
    def finalize(self, response):

        # FIXME: handle cache policy uniformly
        self.set_header("Cache-control", "private")
        self.set_header("max-age", "0")

        if response is None:
            # TODO separate filter message logic (e.g. if response is None and ("p" in self.query_params or "o" in self.query_params))
            filter_message = []
            po_tuples = extract_po_tuples(self.query_params)
            sorted_po_tuples = sorted(po_tuples, key=lambda po: po[2])
            for (p, o, index) in sorted_po_tuples:
                if not index:
                    index = ''
                if not p.startswith("?"):
                    filter_message.append(u" with p{0}=({1})".format(index, p))
                if not o.startswith("?"):
                    filter_message.append(u" with o{0}=({1})".format(index, o))
            self.query_params["filter_message"] = "".join(filter_message)
            self.query_params["page"] = int(self.query_params["page"]) + 1  # Showing real page in response
            msg = _(u"Instances of class ({class_uri}) in graph ({graph_uri}){filter_message}, language=({lang}) and in page=({page}) were not found.")

            response = {
                "warning": msg.format(**self.query_params),
                "items": []
            }
            self.write(response)
        elif isinstance(response, int):  # status code
            self.set_status(response)
        else:
            self.write(response)

        url_schema = build_schema_url(self.query_params, propagate_params=True)
        self.set_header("Content-Type", content_type_profile(url_schema))
예제 #3
0
    def finalize(self, response):
        if response is None:
            # TODO separate filter message logic (e.g. if response is None and ("p" in self.query_params or "o" in self.query_params))
            filter_message = []
            po_tuples = extract_po_tuples(self.query_params)
            sorted_po_tuples = sorted(po_tuples, key=lambda po: po[2])
            for (p, o, index) in sorted_po_tuples:
                if not index:
                    index = ''
                if not p.startswith("?"):
                    filter_message.append(u" with p{0}=({1})".format(index, p))
                if not o.startswith("?"):
                    filter_message.append(u" with o{0}=({1})".format(index, o))
            self.query_params["filter_message"] = "".join(filter_message)
            self.query_params["page"] = int(self.query_params["page"]) + 1  # Showing real page in response
            msg = _(u"Instances of class ({class_uri}) in graph ({graph_uri}){filter_message}, language=({lang}) and in page=({page}) were not found.")

            response = {
                "warning": msg.format(**self.query_params),
                "items": []
            }
            self.write(response)
        elif isinstance(response, int):  # status code
            self.set_status(response)
        else:
            self.write(response)

        self.set_header("Content-Type", content_type_profile(build_schema_url(self.query_params)))
예제 #4
0
 def finalize(self, response):
     if response is None:
         msg = _("There were no search results.")
         raise HTTPError(404, log_message=msg)
     elif isinstance(response, dict):
         self.write(response)
         self.set_header("Content-Type", content_type_profile(build_schema_url(self.query_params)))
     elif isinstance(response, int):  # status code
         self.set_status(response)
예제 #5
0
 def finalize(self, response):
     if isinstance(response, dict):
         self.write(response)
         class_url = build_class_url(self.query_params)
         schema_url = build_schema_url_for_instance(self.query_params, class_url)
         header_value = content_type_profile(schema_url)
         self.set_header("Content-Type", header_value)
     elif isinstance(response, int):  # status code
         self.set_status(response)
예제 #6
0
 def finalize(self, response):
     if isinstance(response, dict):
         self.write(response)
         class_url = build_class_url(self.query_params)
         schema_url = build_schema_url_for_instance(self.query_params,
                                                    class_url)
         header_value = content_type_profile(schema_url)
         self.set_header("Content-Type", header_value)
     elif isinstance(response, int):  # status code
         self.set_status(response)
예제 #7
0
 def finalize(self, response):
     if response is None:
         msg = _("There were no search results.")
         raise HTTPError(404, log_message=msg)
     elif isinstance(response, dict):
         self.write(response)
         self.set_header(
             "Content-Type",
             content_type_profile(build_schema_url(self.query_params)))
     elif isinstance(response, int):  # status code
         self.set_status(response)
예제 #8
0
    def finalize(self, response):
        # FIXME: handle cache policy uniformly
        self.set_header("Cache-control", "private")
        self.set_header("max-age", "0")

        if response is None:
            msg = _("There were no search results.")
            raise HTTPError(404, log_message=msg)
        elif isinstance(response, dict):
            self.write(response)
            url_schema = build_schema_url(self.query_params, propagate_params=True)
            self.set_header("Content-Type", content_type_profile(url_schema))
        elif isinstance(response, int):  # status code
            self.set_status(response)
예제 #9
0
    def finalize(self, response):
        # FIXME: handle uniformly cache policy
        # Meanwhile we do not have a consitent external cache handling policy
        # this avoids a client (such as chrome browser) caching a resource for ever
        self.set_header("Cache-control", "private")
        self.set_header("max-age", "0")

        if isinstance(response, dict):
            self.write(response)
            class_url = build_class_url(self.query_params)
            schema_url = build_schema_url_for_instance(self.query_params, class_url)
            header_value = content_type_profile(schema_url)
            self.set_header("Content-Type", header_value)
        elif isinstance(response, int):  # status code
            self.set_status(response)
예제 #10
0
 def finalize(self, response):
     self.write(response)
     self.set_header(
         "Content-Type",
         content_type_profile(build_schema_url(self.query_params)))
예제 #11
0
 def finalize(self, response):
     self.write(response)
     self.set_header("Content-Type", content_type_profile(build_schema_url(self.query_params)))