Revision: 651
Author: batiste.bieler
Date: Thu Aug 20 09:47:19 2009
Log: Fix few bugs introduced in the previous commit
http://code.google.com/p/django-page-cms/source/detail?r=651

Modified:
  /trunk/pages/http.py
  /trunk/pages/managers.py
  /trunk/pages/views.py

=======================================
--- /trunk/pages/http.py        Thu Aug 20 09:26:45 2009
+++ /trunk/pages/http.py        Thu Aug 20 09:47:19 2009
@@ -55,14 +55,18 @@
      return _dec

  def get_slug_and_relative_path(path):
-    """Return the page's slug and complete path."""
-    if path[-1] == '/':
-        path = path[:-1]
-    slug = path.split("/")[-1]
+    """Return the page's slug and relative path."""
      root = reverse('pages-root')
      if path.startswith(root):
          path = path[len(root):]
-    return slug, path + '/'
+    if len(path) and path[-1] == '/':
+        path = path[:-1]
+    slug = path.split("/")[-1]
+    lang = None
+    if settings.PAGE_USE_LANGUAGE_PREFIX:
+        lang = path.split("/")[0]
+        path = path[(len(lang) + 1):]
+    return slug, path, lang

  def get_template_from_request(request, page=None):
      """
=======================================
--- /trunk/pages/managers.py    Fri Jul 31 01:06:52 2009
+++ /trunk/pages/managers.py    Thu Aug 20 09:47:19 2009
@@ -87,7 +87,7 @@
          """Get a page according to the page's path."""
          from pages.models import Content, Page
          from pages.http import get_slug_and_relative_path
-        slug, rpath = get_slug_and_relative_path(path)
+        slug, path, lang = get_slug_and_relative_path(path)
          page_ids = Content.objects.get_page_ids_by_slug(slug)
          pages_list = self.filter(id__in=page_ids)
          if exclude_drafts:
=======================================
--- /trunk/pages/views.py       Thu Aug 20 09:26:45 2009
+++ /trunk/pages/views.py       Thu Aug 20 09:47:19 2009
@@ -29,12 +29,12 @@
      current_page = False
      template_name = settings.DEFAULT_PAGE_TEMPLATE

+    if path is None:
+        slug, path, lang = get_slug_and_relative_path(request.path)
+
      if lang is None:
          lang = get_language_from_request(request)

-    if path is None:
-        slug, path = get_slug_and_relative_path(request.path)
-
      context = {
          'path': path,
          'pages': pages,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to