Beispiel #1
0
    def resolving(self, ref):
        """
        Context manager which resolves a JSON ``ref`` and enters the
        resolution scope of this ref.

        :argument str ref: reference to resolve

        """

        full_uri = urljoin(self.resolution_scope, ref)
        uri, fragment = urldefrag(full_uri)
        if not uri:
            uri = self.base_uri

        if uri in self.store:
            document = self.store[uri]
        else:
            try:
                document = self.resolve_remote(uri)
            except Exception as exc:
                raise RefResolutionError(exc)

        old_base_uri, self.base_uri = self.base_uri, uri
        try:
            with self.in_scope(uri):
                yield self.resolve_fragment(document, fragment)
        finally:
            self.base_uri = old_base_uri
Beispiel #2
0
 def in_scope(self, scope):
     old_scope = self.resolution_scope
     self.resolution_scope = urljoin(old_scope, scope)
     try:
         yield
     finally:
         self.resolution_scope = old_scope
Beispiel #3
0
def make_external(url):
    return urljoin(request.url_root, url)
Beispiel #4
0
def make_external(url):
    return urljoin(request.url_root, url)
Beispiel #5
0
 def _set_url(self, url):
     if self.service is not None and self.service.base_url is not None and \
             not absolute_url(url):
         return urljoin(self.service.base_url, url)
     return url