def core(self, value, path): """Do it.""" value = String.core(self, value, path) scheme_source, authority_source, path, query, fragment = urlsplit(value) scheme = self.lower_string(scheme_source) authority = self.lower_string(authority_source) if self.inlist(scheme, self.cut_schemes) and self.inlist(authority, self.cut_sites) and ( scheme is not None or authority is not None): scheme = None authority = None if not path and not query and not fragment: path = '/' if not self.inlist(scheme, self.allow_schemes) or not self.inlist(authority, self.allow_sites): raise IncorrectException(self, value) if scheme is None: check_scheme = 'http' else: check_scheme = scheme if self.inlist(scheme, self.local_schemes) and self.inlist(authority, self.local_sites): if self.verify_local is True: if not path and query is not None: raise IncorrectException(self, value) if path and not local_check(path, query): raise IncorrectException(self, value) elif self.verify_local is not False: check = urljoin(check_scheme, self.verify_local, path, query, fragment) if not remote_check(check): raise IncorrectException(self, value) elif self.inlist(scheme, self.verify_schemes) and self.inlist(authority, self.verify_sites): if authority is not None: check = urljoin(check_scheme, authority, path, query, fragment) if not remote_check(check): raise IncorrectException(self, value) value = urljoin(scheme, authority, path, query, fragment) return value
def request_false_response(request): from urlmethods import local_check result = local_check(reverse('notfound')) if result: return HttpResponse('True') else: return HttpResponse('False')