Revision: 638
Author: batiste.bieler
Date: Fri Aug 14 01:06:31 2009
Log: Start some refactoring to address issue 142 and issue 145.
http://code.google.com/p/django-page-cms/source/detail?r=638

Modified:
  /trunk/pages/admin/__init__.py
  /trunk/pages/http.py
  /trunk/pages/templatetags/pages_tags.py
  /trunk/pages/views.py

=======================================
--- /trunk/pages/admin/__init__.py      Sat Aug  8 12:20:57 2009
+++ /trunk/pages/admin/__init__.py      Fri Aug 14 01:06:31 2009
@@ -268,7 +268,7 @@
          the request."""
          form = super(PageAdmin, self).get_form(request, obj, **kwargs)

-        language = get_language_from_request(request, obj)
+        language = get_language_from_request(request)
          form.base_fields['language'].initial = language
          if obj:
              initial_slug = obj.slug(language=language, fallback=False)
=======================================
--- /trunk/pages/http.py        Sun Jul 26 07:34:43 2009
+++ /trunk/pages/http.py        Fri Aug 14 01:06:31 2009
@@ -81,7 +81,7 @@
          return page.get_template()
      return settings.DEFAULT_PAGE_TEMPLATE

-def get_language_from_request(request, current_page=None):
+def get_language_from_request(request):
      """Return the most obvious language according the request."""
      language = request.GET.get('language', None)
      if language:
=======================================
--- /trunk/pages/templatetags/pages_tags.py     Thu Aug 13 09:36:09 2009
+++ /trunk/pages/templatetags/pages_tags.py     Fri Aug 14 01:06:31 2009
@@ -29,11 +29,6 @@

      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['lang'], page)"""

      c = Content.objects.get_content(page, lang, content_type, fallback)
      return c
@@ -213,8 +208,10 @@


  class LoadPagesNode(template.Node):
-    """Load page+ node"""
+    """Load page node."""
      def render(self, context):
+        if (not context.has_key('lang')):
+            context['lang'] = get_language_from_request(request)
          if (not context.has_key('pages')):
              context['pages'] = Page.objects.navigation()
          request = context['request']
@@ -225,7 +222,8 @@
          return ''

  def do_load_pages(parser, token):
-    """Load the navigation pages into the current context
+    """Load the navigation pages, lang, and current_page variables into the
+    current context

      eg:
      <ul>
@@ -242,7 +240,7 @@

  class PlaceholderNode(template.Node):
      """This template node is used to output page content and
-    is also used in the admin to dynamically generate input fields.
+    also in the admin to dynamically generate input fields.

      Keyword arguments:
      name -- the name of the placeholder you want to show/create
=======================================
--- /trunk/pages/views.py       Fri Jul 31 01:06:52 2009
+++ /trunk/pages/views.py       Fri Aug 14 01:06:31 2009
@@ -29,7 +29,7 @@
      current_page = False

      if lang is None:
-        lang = get_language_from_request(request, current_page)
+        lang = get_language_from_request(request)

      if lang not in [key for (key, value) in settings.PAGE_LANGUAGES]:
          raise Http404

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