Permalink
Browse files

Make page_resolver.is_valid_url multisite aware, fixes #1426

  • Loading branch information...
yakky committed Sep 14, 2012
1 parent 3e52d6b commit dd493fd78c7ffe19d04ec88bb290d11f024c13ff
Showing with 6 additions and 2 deletions.
  1. +6 −2 cms/utils/page_resolver.py
@@ -137,16 +137,20 @@ def get_page_from_request(request, use_path=None):
return page
-def is_valid_url(url,instance,create_links=True):
+def is_valid_url(url,instance,create_links=True, site=None):
""" Checks for conflicting urls
"""
if url:
# Url sanity check via regexp
if not any_path_re.match(url):
raise ValidationError(_('Invalid URL, use /my/url format.'))
+ # We only check page FK to site object to allow is_valid_url check on
+ # incomplete Page instances
+ if not site and (instance.site_id):
+ site = instance.site
# Retrieve complete queryset of pages with corresponding URL
# This uses the same resolving function as ``get_page_from_path``
- page_qs = get_page_queryset_from_path(url.strip('/'))
+ page_qs = get_page_queryset_from_path(url.strip('/'), site=site)
url_clashes = []
# If queryset has pages checks for conflicting urls
if page_qs is not None:

0 comments on commit dd493fd

Please sign in to comment.