Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: rfeldbinder/django-cms
...
head fork: rfeldbinder/django-cms
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 21 additions and 18 deletions.
  1. +1 −1  cms/__init__.py
  2. +20 −17 cms/utils/page_resolver.py
2  cms/__init__.py
View
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-__version__ = '2.2rc1'
+__version__ = '2.2rc1-1'
# patch settings
try:
37 cms/utils/page_resolver.py
View
@@ -18,7 +18,7 @@ def get_page_from_path(path, preview=False):
admin_base = reverse('admin:index').lstrip('/')
else:
admin_base = None
-
+
site = Site.objects.get_current()
# Check if this is called from an admin request
if admin_base and path.startswith(admin_base):
@@ -32,22 +32,22 @@ def get_page_from_path(path, preview=False):
except Page.DoesNotExist:
page = None
return page
-
+
if not settings.CMS_MODERATOR or preview:
# We do not use moderator
pages = Page.objects.drafts()
else:
pages = Page.objects.public()
-
+
if not preview:
pages = pages.published()
pages = pages.filter(site=site)
-
+
# Check if there are any pages
if not pages.all_root():
return None
-
+
# get the home page (needed to get the page)
try:
home = pages.get_home()
@@ -58,7 +58,7 @@ def get_page_from_path(path, preview=False):
if not path and home:
page = home
return page
-
+
# title_set__path=path should be clear, get the pages where the path of the
# title object is equal to our path.
if settings.CMS_FLAT_URLS:
@@ -69,27 +69,27 @@ def get_page_from_path(path, preview=False):
page = pages.filter(q).distinct().get()
except Page.DoesNotExist:
return None
-
+
return page
-
+
def get_page_from_request(request, use_path=None):
"""
Gets the current page from a request object.
-
+
URLs can be of the following form (this should help understand the code):
http://server.whatever.com/<some_path>/"pages-root"/some/page/slug
-
+
<some_path>: This can be anything, and should be stripped when resolving
- pages names. This means the CMS is not installed at the root of the
+ pages names. This means the CMS is not installed at the root of the
server's URLs.
"pages-root" This is the root of Django urls for the CMS. It is, in essence
an empty page slug (slug == '')
-
+
The page slug can then be resolved to a Page model object
"""
pages_root = urllib.unquote(reverse("pages-root"))
-
+
# The following is used by cms.middleware.page.CurrentPageMiddleware
if hasattr(request, '_current_page_cache'):
return request._current_page_cache
@@ -101,10 +101,13 @@ def get_page_from_request(request, use_path=None):
if use_path:
path = use_path
else:
- # otherwise strip of the non-cms part of the URL
- path = request.path[len(pages_root):-1]
-
+ # otherwise strip of the non-cms part of the URL
+ if request.path.endswith('/'):
+ path = request.path[len(pages_root):-1]
+ else:
+ path = request.path[len(pages_root):]
+
page = get_page_from_path(path, preview)
-
+
request._current_page_cache = page
return page

No commit comments for this range

Something went wrong with that request. Please try again.