def normalize(uristr): """Translate the given URI into a normalized form.""" uristr = uristr.encode('utf-8') # Strip proxy prefix for proxied URLs for scheme in URL_SCHEMES: if uristr.startswith(VIA_PREFIX + scheme + ':'): uristr = uristr[len(VIA_PREFIX):] break # Try to extract the scheme uri = urlparse.urlsplit(uristr) # If this isn't a URL, we don't perform any normalization if uri.scheme.lower() not in URL_SCHEMES: return text_type(uristr, 'utf-8') # Don't perform normalization on URLs with no hostname. if uri.hostname is None: return text_type(uristr, 'utf-8') scheme = _normalize_scheme(uri) netloc = _normalize_netloc(uri) path = _normalize_path(uri) query = _normalize_query(uri) fragment = None uri = urlparse.SplitResult(scheme, netloc, path, query, fragment) return text_type(uri.geturl(), 'utf-8')
def pyramid_request(db_session, fake_feature, pyramid_settings): """Dummy Pyramid request object.""" request = testing.DummyRequest(db=db_session, feature=fake_feature) request.authority = text_type(request.domain) request.create_form = mock.Mock() request.registry.settings = pyramid_settings return request
def pyramid_request(db_session, fake_feature, pyramid_settings): """Dummy Pyramid request object.""" request = testing.DummyRequest(db=db_session, feature=fake_feature) request.auth_domain = text_type(request.domain) request.create_form = mock.Mock() request.registry.settings = pyramid_settings return request