Author: batiste.bieler
Date: Sat Feb 21 04:32:21 2009
New Revision: 358

Modified:
    trunk/pages/managers.py
    trunk/pages/models.py
    trunk/pages/templatetags/pages_tags.py
    trunk/pages/views.py

Log:
Apply the patch of issue 51, but in a sligthly different way

Modified: trunk/pages/managers.py
==============================================================================
--- trunk/pages/managers.py     (original)
+++ trunk/pages/managers.py     Sat Feb 21 04:32:21 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
  import itertools
  from datetime import datetime

@@ -124,12 +125,16 @@
              return content.body
          except self.model.DoesNotExist:
              pass
+        # requested language not found. Try other languages on after
+        # the other
          if language_fallback:
-            try:
-                content = self.filter(page=page,  
type=cnttype).latest(latest_by)
-                return content.body
-            except self.model.DoesNotExist:
-                pass
+            for lang in settings.PAGE_LANGUAGES:
+                try:
+                    content = self.filter(language=lang[0], page=page,
+                        type=cnttype).latest(latest_by)
+                    return content.body
+                except self.model.DoesNotExist:
+                    pass
          return None

      def get_content_slug_by_slug(self, slug, site=None,  
latest_by='creation_date'):

Modified: trunk/pages/models.py
==============================================================================
--- trunk/pages/models.py       (original)
+++ trunk/pages/models.py       Sat Feb 21 04:32:21 2009
@@ -35,7 +35,7 @@
      PAGE_LANGUAGES_KEY = "page_%d_languages"
      PAGE_URL_KEY = "page_%d_language_%s_url"
      PAGE_TEMPLATE_KEY = "page_%d_template"
-    PAGE_CHILDREN_KEY = "page_children_%d_%d"
+    #PAGE_CHILDREN_KEY = "page_children_%d_%d"
      PAGE_CONTENT_KEY = "page_content_%d_%s_%s"

      author = models.ForeignKey(User, verbose_name=_('author'))
@@ -123,11 +123,9 @@

          languages = []
          for lang in settings.PAGE_LANGUAGES:
-            try:
-                if Content.objects.filter(page=self, type="slug",  
language=lang[0]).count() > 0:
-                    languages.append(lang[0])
-            except Content.DoesNotExist:
-                pass
+            # one request by language to avoid to get huge revisions
+            if Content.objects.filter(language=lang[0], page=self,  
type="slug").latest.count() > 0:
+               languages.append(lang[0])

          cache.set(self.PAGE_LANGUAGES_KEY % (self.id), languages)


Modified: trunk/pages/templatetags/pages_tags.py
==============================================================================
--- trunk/pages/templatetags/pages_tags.py      (original)
+++ trunk/pages/templatetags/pages_tags.py      Sat Feb 21 04:32:21 2009
@@ -39,10 +39,11 @@
      request = context['request']
      site = request.site

-    children = cache.get(Page.PAGE_CHILDREN_KEY % (page.id, site.id))
-    if children is None:
-        children = get_page_children_for_site(page, site)
-        cache.set(Page.PAGE_CHILDREN_KEY % (page.id, site.id), children)
+    # TODO: is it worthwhile to have this cached?
+    #children = cache.get(Page.PAGE_CHILDREN_KEY % (page.id, site.id))
+    #if children is None:
+    children = get_page_children_for_site(page, site)
+    #cache.set(Page.PAGE_CHILDREN_KEY % (page.id, site.id), children)

      if 'current_page' in context:
          current_page = context['current_page']

Modified: trunk/pages/views.py
==============================================================================
--- trunk/pages/views.py        (original)
+++ trunk/pages/views.py        Sat Feb 21 04:32:21 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
  from django.http import Http404
  from django.shortcuts import get_object_or_404
  from django.contrib.sites.models import SITE_CACHE

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