def is_valid_url(url, instance, create_links=True, site=None):
 page_root = unquote(reverse('pages-root'))
 if (url and (url != page_root)):
  if (not any_path_re.match(url)):
   raise ValidationError(_('Invalid URL, use /my/url format.'))
  if ((not site) and instance.site_id):
   site = instance.site
  if url.startswith(page_root):
   url = url[len(page_root):]
  page_qs = get_page_queryset_from_path(url.strip('/'), site=site, draft=instance.publisher_is_draft)
  url_clashes = []
  for page in page_qs:
   if (page and (page.publisher_public_id != instance.pk) and (page.pk != instance.pk)):
    if create_links:
     url_clashes.append(('<a href="%(page_url)s%(pk)s" target="_blank">%(page_title)s</a>' % {'page_url': admin_reverse('cms_page_changelist'), 'pk': page.pk, 'page_title': force_text(page)}))
    else:
     url_clashes.append(("'%s'" % page))
  if url_clashes:
   raise ValidationError(mark_safe((ungettext_lazy('Page %(pages)s has the same url \'%(url)s\' as current page "%(instance)s".', 'Pages %(pages)s have the same url \'%(url)s\' as current page "%(instance)s".', len(url_clashes)) % {'pages': ', '.join(url_clashes), 'url': url, 'instance': instance})))
 return True

def is_valid_url ( url , instance , create_links = True , site = None ) : page_root = unquote ( reverse ( 'pages-root' ) ) if ( url and ( url != page_root ) ) : if ( not any_path_re . match ( url ) ) : raise ValidationError ( _ ( 'Invalid URL, use /my/url format.' ) ) if ( ( not site ) and instance . site_id ) : site = instance . site if url . startswith ( page_root ) : url = url [ len ( page_root ) : ] page_qs = get_page_queryset_from_path ( url . strip ( '/' ) , site = site , draft = instance . publisher_is_draft ) url_clashes = [ ] for page in page_qs : if ( page and ( page . publisher_public_id != instance . pk ) and ( page . pk != instance . pk ) ) : if create_links : url_clashes . append ( ( '<a href="%(page_url)s%(pk)s" target="_blank">%(page_title)s</a>' % { 'page_url' : admin_reverse ( 'cms_page_changelist' ) , 'pk' : page . pk , 'page_title' : force_text ( page ) } ) ) else : url_clashes . append ( ( "'%s'" % page ) ) if url_clashes : raise ValidationError ( mark_safe ( ( ungettext_lazy ( 'Page %(pages)s has the same url \'%(url)s\' as current page "%(instance)s".' , 'Pages %(pages)s have the same url \'%(url)s\' as current page "%(instance)s".' , len ( url_clashes ) ) % { 'pages' : ', ' . join ( url_clashes ) , 'url' : url , 'instance' : instance } ) ) ) return True
tests a url to ensure it doesnt appear to be a blacklisted ip range .