Revision: 636
Author: batiste.bieler
Date: Thu Aug 13 09:36:09 2009
Log: Fix bug 145. Now if lang variable is not present in the contexct, the  
default language is used.
http://code.google.com/p/django-page-cms/source/detail?r=636

Modified:
  /trunk/pages/templatetags/pages_tags.py

=======================================
--- /trunk/pages/templatetags/pages_tags.py     Fri Aug  7 03:54:33 2009
+++ /trunk/pages/templatetags/pages_tags.py     Thu Aug 13 09:36:09 2009
@@ -21,7 +21,7 @@
          return ''

      if not lang and 'lang' in context:
-        lang = context['lang']
+        lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)

      # if the page is a SafeUnicode, try to use it like a slug
      if isinstance(page, SafeUnicode) or isinstance(page, unicode):
@@ -56,7 +56,7 @@
  def pages_menu(context, page, url='/'):
      """Render a nested list of all children of the given page, including
      this page"""
-    lang = context['lang']
+    lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)
      path = context['path']
      site_id = None
      children = page.get_children_for_frontend()
@@ -69,7 +69,7 @@
  def pages_sub_menu(context, page, url='/'):
      """Get the root page of the given page and
      render a nested list of all root's children pages"""
-    lang = context['lang']
+    lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)
      path = context['path']
      root = page.get_root()
      children = root.get_children_for_frontend()
@@ -94,7 +94,7 @@
      page_languages = settings.PAGE_LANGUAGES
      has_permission = page.has_page_permission(request)
      PAGES_MEDIA_URL = settings.PAGES_MEDIA_URL
-    lang = context.get('lang', None)
+    lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)

      return locals()
  pages_admin_menu = register.inclusion_tag('admin/pages/page/menu.html',
@@ -134,7 +134,7 @@
      page -- the page object or a slug string
      lang -- the wanted language (defaults to None, uses request object  
else)
      """
-    lang = context.get('lang', None)
+    lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)
      # if the page is a SafeUnicode, try to use it like a slug
      if isinstance(page, SafeUnicode) or isinstance(page, unicode):
          page = Page.objects.from_path(page, lang)
@@ -297,7 +297,7 @@
          if not self.page in context:
              return ''

-        lang = context.get('lang', None)
+        lang = context.get('lang', settings.PAGE_DEFAULT_LANGUAGE)
          content = Content.objects.get_content(context[self.page], lang,
                                                self.name, True)
          if not content:

--~--~---------~--~----~------------~-------~--~----~
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