Author: batiste.bieler
Date: Sat Jun  6 06:10:14 2009
New Revision: 549

Modified:
    trunk/pages/templatetags/pages_tags.py

Log:
Fix issue 104

Modified: trunk/pages/templatetags/pages_tags.py
==============================================================================
--- trunk/pages/templatetags/pages_tags.py      (original)
+++ trunk/pages/templatetags/pages_tags.py      Sat Jun  6 06:10:14 2009
@@ -19,20 +19,26 @@
      request = context.get('request', False)
      if not request or not page:
          return ''
-    if lang is None:
-        if 'lang' in context:
-            lang = context['lang']
-        else:
-            lang = get_language_from_request(context['request'], page)

-    c = ''
+    absolute_lang = None
+    if lang:
+        absolute_lang = lang
+    elif 'lang' in context:
+        absolute_lang = context['lang']
+
      # if the page is a SafeUnicode, try to use it like a slug
      if isinstance(page, SafeUnicode) or isinstance(page, unicode):
-        c = Content.objects.filter(type='slug', language=lang, body=page)
-        if len(c):
-            page = c[0].page
-    else:
-        c = Content.objects.get_content(page, lang, content_type, fallback)
+        page = get_page_from_slug(page, context['request'], absolute_lang)
+
+    if not page:
+        return ''
+
+    # now that we are sure to have a page object, we can found the  
content's
+    # language more accuratly
+    if not absolute_lang:
+        absolute_lang = get_language_from_request(context['request'], page)
+
+    c = Content.objects.get_content(page, absolute_lang, content_type,  
fallback)
      return c

  """Fitlers"""

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