Browse files

appresolver now 'flattens' urlpatterns to fix some resolving issues

  • Loading branch information...
1 parent 4ba4c36 commit e5cb6446ddd99ea856c77eb5b249f9577886d4d4 ojii committed Jun 8, 2010
Showing with 10 additions and 0 deletions.
  1. +10 −0 cms/appresolver.py
View
10 cms/appresolver.py
@@ -85,6 +85,15 @@ def recurse_patterns(path, pattern_list, page_id):
newpatterns.append(resolver)
return newpatterns
+def _flatten_patterns(patterns):
+ flat = []
+ for pattern in patterns:
+ if isinstance(pattern, RegexURLResolver):
+ flat += _flatten_patterns(pattern.url_patterns)
+ else:
+ flat.append(pattern)
+ return flat
+
def get_patterns_for_title(path, title):
"""
Resolve the urlconf module for a path+title combination
@@ -106,6 +115,7 @@ def get_patterns_for_title(path, title):
path += '/'
page_id = title.page.id
patterns += recurse_patterns(path, pattern_list, page_id)
+ patterns = _flatten_patterns(patterns)
return patterns

0 comments on commit e5cb644

Please sign in to comment.