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
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
def make_external(url): return urljoin(request.url_root, url)
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