def _rel_abs(self, url): if not hasattr(url, 'relative_to'): cat_url = self.catalog_url if '://' in url: abs_url = URL(url, cat_url) else: abs_url = URL(URL(url, cat_url).absolute, cat_url) rel_url = abs_url.relative_to(cat_url) else: abs_url = url.absolute rel_url = url.relative_to(self.catalog_url) return rel_url, abs_url
def _rel_abs(self, url): if not hasattr(url, 'relative_to'): cat_url = self.catalog_url if '://' in url: abs_url = URL(url, cat_url) else: abs_url = URL(URL(url, cat_url).absolute, cat_url) rel_url = abs_url.relative_to(cat_url) else: abs_url = url.absolute rel_url = url.relative_to(self.catalog_url) return rel_url, abs_url
def __init__(self, session, catalog_url, **members): self.session = session self.catalog_url = catalog_url catalog_url_absolute, frag = urllib.parse.urldefrag(catalog_url.absolute) # Normalized keys stores a dictionary of shortest relative URLs # obtained via URL.relative_to that maps to the arbitrary URL relative # or absolute that the client submitted. We can use this to always # key the tuples by relative URL regardless of what kind of URL the # user asks to fetch an item by. normalized_keys = {} for entity_url, tup in six.iteritems(members): url = entity_url if not hasattr(url, "relative_to"): # Faster than isinstance(url, URL) url = URL(url, catalog_url_absolute) members[url] = Tuple(session, url, **tup) if tup is not None else None normalized_keys[url.relative_to(catalog_url)] = url self.normalized_keys = normalized_keys elements.JSONObject.__init__(self, **members)
def __init__(self, session, catalog_url, **members): self.session = session self.catalog_url = catalog_url catalog_url_absolute, frag = urllib.parse.urldefrag(catalog_url.absolute) # Normalized keys stores a dictionary of shortest relative URLs # obtained via URL.relative_to that maps to the arbitrary URL relative # or absolute that the client submitted. We can use this to always # key the tuples by relative URL regardless of what kind of URL the # user asks to fetch an item by. normalized_keys = {} for entity_url, tup in six.iteritems(members): if tup is not None: url = entity_url if not hasattr(url, "relative_to"): # Faster than isinstance(url, URL) url = URL(url, catalog_url_absolute) members[url] = Tuple(session, url, **tup) normalized_keys[url.relative_to(catalog_url)] = url self.normalized_keys = normalized_keys elements.JSONObject.__init__(self, **members)