Skip to content

Commit

Permalink
fixes #284 trailing slash setting is taken into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Lauber committed Dec 8, 2009
1 parent 31ff505 commit 41aa54d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cms/appresolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def resolve_page_id(self, path):
assigned.
"""
tried = []
print path
match = self.regex.search(path)
if match:
new_path = path[match.end():]
Expand All @@ -53,6 +54,8 @@ def resolve_page_id(self, path):
else:
return self.page_id
tried.append(pattern.regex.pattern)
print tried
print new_path
raise Resolver404, {'tried': tried, 'path': new_path}


Expand Down Expand Up @@ -101,7 +104,7 @@ def __init__(self, path, title, default_kwargs={}):
if settings.APPEND_SLASH:
regex += r'/'
urlconf_name = title.application_urls

print regex
# assign page_id to resolver, so he knows on which page he was assigned
self.page_id = title.page_id
super(ApplicationRegexUrlResolver, self).__init__(regex, urlconf_name, default_kwargs)
Expand Down Expand Up @@ -166,11 +169,16 @@ def urlpatterns(self):
else:
path = title.path
mixid = "%s:%s" % (path + "/", title.application_urls)
print path
print mixid
if mixid in included:
# don't add the same thing twice
continue
if not settings.APPEND_SLASH:
path += '/'
urls.append(ApplicationRegexUrlResolver(path, title))
included.append(mixid)
print urls
self._urlpatterns = urls
return self._urlpatterns

Expand Down
7 changes: 6 additions & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
from django.conf import settings
from cms.views import details

if settings.APPEND_SLASH:
reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug')
else:
reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', details, name='pages-details-by-slug')

urlpatterns = (
# Public pages
url(r'^$', details, {'slug':''}, name='pages-root'),
url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug'),
reg,
)

if settings.CMS_APPLICATIONS_URLS:
Expand Down

0 comments on commit 41aa54d

Please sign in to comment.