Author: leidel
Date: Sat Dec 13 03:24:36 2008
New Revision: 282

Added:
    branches/page-blocks/pages/conf/
    branches/page-blocks/pages/conf/__init__.py
    branches/page-blocks/pages/conf/pages_settings.py
Removed:
    branches/page-blocks/pages/settings.py
Modified:
    branches/page-blocks/example/settings.py
    branches/page-blocks/pages/admin/__init__.py
    branches/page-blocks/pages/admin/forms.py
    branches/page-blocks/pages/admin/views.py
    branches/page-blocks/pages/admin/widgets.py
    branches/page-blocks/pages/context_processors.py
    branches/page-blocks/pages/managers.py
    branches/page-blocks/pages/models.py
    branches/page-blocks/pages/templates/pages/menu.html
    branches/page-blocks/pages/templatetags/pages_tags.py
    branches/page-blocks/pages/urls.py
    branches/page-blocks/pages/utils.py
    branches/page-blocks/pages/views.py

Log:
Refactored settings handling and renamed the settings to PAGES_*.

Modified: branches/page-blocks/example/settings.py
==============================================================================
--- branches/page-blocks/example/settings.py    (original)
+++ branches/page-blocks/example/settings.py    Sat Dec 13 03:24:36 2008
@@ -102,9 +102,9 @@
      ('en', gettext_noop('English')),
  )

-DEFAULT_PAGE_TEMPLATE = 'index.html'
+PAGES_DEFAULT_TEMPLATE = 'index.html'

-PAGE_TEMPLATES = (
+PAGES_TEMPLATES = (
      ('nice.html', 'nice one'),
      ('cool.html', 'cool one'),
  )

Modified: branches/page-blocks/pages/admin/__init__.py
==============================================================================
--- branches/page-blocks/pages/admin/__init__.py        (original)
+++ branches/page-blocks/pages/admin/__init__.py        Sat Dec 13 03:24:36 2008
@@ -5,12 +5,11 @@
  from django.contrib import admin
  from django.utils.translation import ugettext as _, ugettext_lazy
  from django.utils.encoding import force_unicode
-from django.conf import settings as global_settings
  from django.db import models
  from django.http import HttpResponseRedirect
  from django.contrib.admin.util import unquote

-from pages import settings
+from pages.conf import settings
  from pages.models import Page, Content, tagging
  from pages.views import details
  from pages.utils import get_template_from_request,  
has_page_add_permission, \
@@ -30,17 +29,17 @@
      general_fields = ['title', 'slug', 'status', 'sites']
      insert_point = general_fields.index('status') + 1

-    if settings.PAGE_TAGGING:
+    if settings.PAGES_TAGGING:
          general_fields.insert(insert_point, 'tags')

      # Add support for future dating and expiration based on settings.
-    if settings.PAGE_SHOW_END_DATE:
+    if settings.PAGES_SHOW_END_DATE:
          general_fields.insert(insert_point, 'publication_end_date')
-    if settings.PAGE_SHOW_START_DATE:
+    if settings.PAGES_SHOW_START_DATE:
          general_fields.insert(insert_point, 'publication_date')

      normal_fields = ['language']
-    if settings.PAGE_TEMPLATES:
+    if settings.PAGES_TEMPLATES:
          normal_fields.append('template')

      fieldsets = (
@@ -100,7 +99,7 @@
          This takes into account the USE_I18N setting. If it's set to  
False, the
          generated JavaScript will be leaner and faster.
          """
-        if global_settings.USE_I18N:
+        if settings.USE_I18N:
              from django.views.i18n import javascript_catalog
          else:
              from django.views.i18n import null_javascript_catalog as  
javascript_catalog
@@ -132,8 +131,8 @@
                  if change:
                      if placeholder.name not in self.mandatory_placeholders:
                          # we need create a new content if revision is  
enabled
-                        if settings.PAGE_CONTENT_REVISION and  
placeholder.name \
-                                not in  
settings.PAGE_CONTENT_REVISION_EXCLUDE_LIST:
+                        if settings.PAGES_CONTENT_REVISION and  
placeholder.name \
+                                not in  
settings.PAGES_CONTENT_REVISION_EXCLUDE_LIST:
                              Content.objects.create_content_if_changed(obj,  
language,
                                  placeholder.name,  
form.cleaned_data[placeholder.name])
                          else:
@@ -199,9 +198,9 @@
              form.base_fields['slug'].label = _('Slug')

          template = get_template_from_request(request, obj)
-        if settings.PAGE_TEMPLATES:
-            template_choices = list(settings.PAGE_TEMPLATES)
-            template_choices.insert(0, (settings.DEFAULT_PAGE_TEMPLATE,  
_('Default template')))
+        if settings.PAGES_TEMPLATES:
+            template_choices = list(settings.PAGES_TEMPLATES)
+            template_choices.insert(0, (settings.PAGES_DEFAULT_TEMPLATE,  
_('Default template')))
              form.base_fields['template'].choices = template_choices
              form.base_fields['template'].initial = force_unicode(template)

@@ -240,7 +239,7 @@
              extra_context = {
                  'placeholders': get_placeholders(request, template),
                  'language': get_language_from_request(request),
-                'traduction_language': settings.PAGE_LANGUAGES,
+                'traduction_language': settings.PAGES_LANGUAGES,
                  'page': obj,
              }
          return super(PageAdmin, self).change_view(request, object_id,  
extra_context)
@@ -249,7 +248,7 @@
          """
          Return true if the current user has permission to add a new page.
          """
-        if not settings.PAGE_PERMISSION:
+        if not settings.PAGES_PERMISSION:
              return super(PageAdmin, self).has_add_permission(request)
          else:
              return has_page_add_permission(request)
@@ -259,7 +258,7 @@
          Return true if the current user has permission on the page.
          Return the string 'All' if the user has all rights.
          """
-        if settings.PAGE_PERMISSION and obj is not None:
+        if settings.PAGES_PERMISSION and obj is not None:
              return obj.has_page_permission(request)
          return super(PageAdmin, self).has_change_permission(request, obj)

@@ -268,7 +267,7 @@
          Return true if the current user has permission on the page.
          Return the string 'All' if the user has all rights.
          """
-        if settings.PAGE_PERMISSION and obj is not None:
+        if settings.PAGES_PERMISSION and obj is not None:
              return obj.has_page_permission(request)
          return super(PageAdmin, self).has_delete_permission(request, obj)

@@ -318,6 +317,6 @@

  #admin.site.register(Content, ContentAdmin)

-if settings.PAGE_PERMISSION:
+if settings.PAGES_PERMISSION:
      from pages.models import PagePermission
      admin.site.register(PagePermission)

Modified: branches/page-blocks/pages/admin/forms.py
==============================================================================
--- branches/page-blocks/pages/admin/forms.py   (original)
+++ branches/page-blocks/pages/admin/forms.py   Sat Dec 13 03:24:36 2008
@@ -2,7 +2,7 @@
  from django.template.defaultfilters import slugify
  from django.utils.translation import ugettext_lazy as _

-from pages import settings
+from pages.conf import settings
  from pages.models import Page, Content, tagging

  class PageForm(forms.ModelForm):
@@ -18,13 +18,13 @@
      )
      language = forms.ChoiceField(
          label=_('Language'),
-        choices=settings.PAGE_LANGUAGES,
+        choices=settings.PAGES_LANGUAGES,
          help_text=_('The current language of the content fields.'),
      )
      template = forms.ChoiceField(
          required=False,
          label=_('Template'),
-        choices=settings.PAGE_TEMPLATES,
+        choices=settings.PAGES_TEMPLATES,
          help_text=_('The template used to render the content.')
      )
      if tagging:
@@ -37,7 +37,7 @@

      def clean_slug(self):
          slug = slugify(self.cleaned_data['slug'])
-        if settings.PAGE_UNIQUE_SLUG_REQUIRED:
+        if settings.PAGES_UNIQUE_SLUG_REQUIRED:
              if self.instance.id:
                  if  
Content.objects.exclude(page=self.instance).filter(body=slug,  
type="slug").count():
                      raise forms.ValidationError(_('Another page with this  
slug already exists'))

Modified: branches/page-blocks/pages/admin/views.py
==============================================================================
--- branches/page-blocks/pages/admin/views.py   (original)
+++ branches/page-blocks/pages/admin/views.py   Sat Dec 13 03:24:36 2008
@@ -2,7 +2,7 @@
  from django.http import HttpResponse, Http404
  from django.contrib.admin.views.decorators import staff_member_required

-from pages import settings
+from pages.conf import settings
  from pages.models import Page, Content

  from pages.utils import auto_render
@@ -30,7 +30,7 @@
          if not content:
              raise Http404
          page = Page.objects.get(pk=page_id)
-        if settings.PAGE_CONTENT_REVISION:
+        if settings.PAGES_CONTENT_REVISION:
              Content.objects.create_content_if_changed(page, language_id,
                                                        content_id, content)
          else:
@@ -59,7 +59,7 @@

  def valid_targets_list(request, page_id):
      """A list of valid targets to move a page"""
-    if not settings.PAGE_PERMISSION:
+    if not settings.PAGES_PERMISSION:
          perms = "All"
      else:
          from pages.models import PagePermission

Modified: branches/page-blocks/pages/admin/widgets.py
==============================================================================
--- branches/page-blocks/pages/admin/widgets.py (original)
+++ branches/page-blocks/pages/admin/widgets.py Sat Dec 13 03:24:36 2008
@@ -1,11 +1,10 @@
  from os.path import join
-from django.conf import settings
  from django.forms import TextInput, Textarea
  from django.utils.safestring import mark_safe
  from django.template import RequestContext
  from django.template.loader import render_to_string

-from pages.settings import PAGES_MEDIA_URL
+from pages.conf import settings
  from pages.models import Page, tagging

  if tagging:
@@ -14,7 +13,7 @@

      class AutoCompleteTagInput(TextInput):
          class Media:
-            js = [join(PAGES_MEDIA_URL, path) for path in (
+            js = [join(settings.PAGES_MEDIA_URL, path) for path in (
                  'javascript/jquery.js',
                  'javascript/jquery.bgiframe.min.js',
                  'javascript/jquery.ajaxQueue.js',
@@ -33,11 +32,11 @@

  class RichTextarea(Textarea):
      class Media:
-        js = [join(PAGES_MEDIA_URL, path) for path in (
+        js = [join(settings.PAGES_MEDIA_URL, path) for path in (
              'javascript/jquery.js',
          )]
          css = {
-            'all': [join(PAGES_MEDIA_URL, path) for path in (
+            'all': [join(settings.PAGES_MEDIA_URL, path) for path in (
                  'css/rte.css',
              )]
          }
@@ -50,14 +49,14 @@
          rendered = super(RichTextarea, self).render(name, value, attrs)
          context = {
              'name': name,
-            'PAGES_MEDIA_URL': PAGES_MEDIA_URL,
+            'settings.PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL,
          }
          return rendered + mark_safe(render_to_string(
              'admin/pages/page/widgets/richtextarea.html', context))

  class WYMEditor(Textarea):
      class Media:
-        js = [join(PAGES_MEDIA_URL, path) for path in (
+        js = [join(settings.PAGES_MEDIA_URL, path) for path in (
              'javascript/jquery.js',
              'wymeditor/jquery.wymeditor.js',
              'wymeditor/plugins/resizable/jquery.wymeditor.resizable.js',
@@ -75,20 +74,20 @@
          context = {
              'name': name,
              'language': self.language,
-            'PAGES_MEDIA_URL': PAGES_MEDIA_URL,
+            'settings.PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL,
          }
          return rendered + mark_safe(render_to_string(
              'admin/pages/page/widgets/wymeditor.html', context))

  class markItUpMarkdown(Textarea):
      class Media:
-        js = [join(PAGES_MEDIA_URL, path) for path in (
+        js = [join(settings.PAGES_MEDIA_URL, path) for path in (
              'javascript/jquery.js',
              'markitup/jquery.markitup.js',
              'markitup/sets/markdown/set.js',
          )]
          css = {
-            'all': [join(PAGES_MEDIA_URL, path) for path in (
+            'all': [join(settings.PAGES_MEDIA_URL, path) for path in (
                  'markitup/skins/simple/style.css',
                  'markitup/sets/markdown/style.css',
              )]
@@ -104,13 +103,13 @@

  class markItUpHTML(Textarea):
      class Media:
-        js = [join(PAGES_MEDIA_URL, path) for path in (
+        js = [join(settings.PAGES_MEDIA_URL, path) for path in (
              'javascript/jquery.js',
              'markitup/jquery.markitup.js',
              'markitup/sets/default/set.js',
          )]
          css = {
-            'all': [join(PAGES_MEDIA_URL, path) for path in (
+            'all': [join(settings.PAGES_MEDIA_URL, path) for path in (
                  'markitup/skins/simple/style.css',
                  'markitup/sets/default/style.css',
              )]

Added: branches/page-blocks/pages/conf/__init__.py
==============================================================================
--- (empty file)
+++ branches/page-blocks/pages/conf/__init__.py Sat Dec 13 03:24:36 2008
@@ -0,0 +1,19 @@
+from django.conf import settings
+from pages.conf import pages_settings
+
+class CombinedSettingsHolder(object):
+    """
+    Convenience object for access to custom pages application settings,
+    which enforces default settings when the global settings module does  
not
+    contain the appropriate settings.
+    """
+    def __init__(self, global_settings, default_settings):
+        self.global_settings = global_settings
+        self.default_settings = default_settings
+
+    def __getattr__(self, name):
+        if hasattr(self.global_settings, name):
+            return getattr(self.global_settings, name)
+        return getattr(self.default_settings, name)
+
+settings = CombinedSettingsHolder(settings, pages_settings)

Added: branches/page-blocks/pages/conf/pages_settings.py
==============================================================================
--- (empty file)
+++ branches/page-blocks/pages/conf/pages_settings.py   Sat Dec 13 03:24:36  
2008
@@ -0,0 +1,47 @@
+from os.path import join
+
+# Which template should be used.
+PAGES_DEFAULT_TEMPLATE = None
+
+# Could be set to None if you don't need multiple templates.
+PAGES_TEMPLATES = ()
+
+# Whether to enable permissions.
+PAGES_PERMISSION = True
+
+# Whether to enable tagging.
+PAGES_TAGGING = True
+
+# Whether to only allow unique slugs.
+PAGES_UNIQUE_SLUG_REQUIRED = True
+
+# Whether to enable revisions.
+PAGES_CONTENT_REVISION = True
+
+# Defines which languages should be offered.
+PAGES_LANGUAGES = settings.LANGUAGES
+
+# Defines which language should be used by default and falls back to  
LANGUAGE_CODE
+PAGES_DEFAULT_LANGUAGE = settings.LANGUAGE_CODE[:2]
+
+# Defines how long page content should be cached, including navigation and  
admin menu.
+PAGES_CONTENT_CACHE_DURATION = 60
+
+# You can exclude some placeholder from the revision process
+PAGES_CONTENT_REVISION_EXCLUDE_LIST = ()
+
+# Sanitize the user input with html5lib
+PAGES_SANITIZE_USER_INPUT = False
+
+# URL that handles pages' media and uses <MEDIA_ROOT>/pages by default.
+PAGES_MEDIA_URL = join(settings.MEDIA_URL, 'pages/')
+
+# Show the publication date field in the admin, allows for future dating
+# Changing this from True to False could cause some weirdness.  If that is  
required,
+# you should update your database to correct any future dated pages
+PAGES_SHOW_START_DATE = False
+
+# Show the publication end date field in the admin, allows for page  
expiration
+# Changing this from True to False could cause some weirdness.  If that is  
required,
+# you should update your database and null any pages with  
publication_end_date set.
+PAGES_SHOW_END_DATE = False

Modified: branches/page-blocks/pages/context_processors.py
==============================================================================
--- branches/page-blocks/pages/context_processors.py    (original)
+++ branches/page-blocks/pages/context_processors.py    Sat Dec 13 03:24:36  
2008
@@ -1,4 +1,4 @@
-from pages import settings
+from pages.conf import settings

  def media(request):
      """

Modified: branches/page-blocks/pages/managers.py
==============================================================================
--- branches/page-blocks/pages/managers.py      (original)
+++ branches/page-blocks/pages/managers.py      Sat Dec 13 03:24:36 2008
@@ -4,7 +4,7 @@
  from django.db.models import Q
  from datetime import datetime

-from pages import settings
+from pages.conf import settings

  class PageManager(models.Manager):
      def on_site(self, site=None):
@@ -37,10 +37,10 @@
      def published(self, site=None):
          pub = self.on_site(site).filter(status=self.model.PUBLISHED)

-        if settings.PAGE_SHOW_START_DATE:
+        if settings.PAGES_SHOW_START_DATE:
              pub = pub.filter(publication_date__lte=datetime.now())

-        if settings.PAGE_SHOW_END_DATE:
+        if settings.PAGES_SHOW_END_DATE:
              pub = pub.filter(
                  Q(publication_end_date__gt=datetime.now()) |
                  Q(publication_end_date__isnull=True)
@@ -49,7 +49,7 @@

      def drafts(self, site=None):
          pub = self.on_site(site).filter(status=self.model.DRAFT)
-        if settings.PAGE_SHOW_START_DATE:
+        if settings.PAGES_SHOW_START_DATE:
              pub = pub.filter(publication_date__gte=datetime.now())
          return pub

@@ -73,7 +73,7 @@
          """
          set or create a content for a particular page and language
          """
-        if settings.PAGE_SANITIZE_USER_INPUT:
+        if settings.PAGES_SANITIZE_USER_INPUT:
              body = self.sanitize(body)
          try:
              content = self.filter(page=page, language=language,
@@ -89,7 +89,7 @@
          """
          set or create a content for a particular page and language
          """
-        if settings.PAGE_SANITIZE_USER_INPUT:
+        if settings.PAGES_SANITIZE_USER_INPUT:
              body = self.sanitize(body)
          try:
              content = self.filter(page=page, language=language,

Modified: branches/page-blocks/pages/models.py
==============================================================================
--- branches/page-blocks/pages/models.py        (original)
+++ branches/page-blocks/pages/models.py        Sat Dec 13 03:24:36 2008
@@ -11,7 +11,7 @@
  from django.contrib.sites.models import Site

  import mptt
-from pages import settings
+from pages.conf import settings
  from pages.managers import PageManager, ContentManager,  
PagePermissionManager

  try:
@@ -20,7 +20,7 @@
  except ImproperlyConfigured:
      tagging = False

-if not settings.PAGE_TAGGING:
+if not settings.PAGES_TAGGING:
      tagging = False

  class Page(models.Model):
@@ -63,7 +63,7 @@
              self.publication_date = datetime.now()
          # Drafts should not, unless they have been set to the future
          if self.status == self.DRAFT:
-            if settings.PAGE_SHOW_START_DATE:
+            if settings.PAGES_SHOW_START_DATE:
                  if self.publication_date and self.publication_date <=  
datetime.now():
                      self.publication_date = None
              else:
@@ -75,11 +75,11 @@
          get the calculated status of the page based on published_date,
          published_end_date, and status
          """
-        if settings.PAGE_SHOW_START_DATE:
+        if settings.PAGES_SHOW_START_DATE:
              if self.publication_date > datetime.now():
                  return self.DRAFT

-        if settings.PAGE_SHOW_END_DATE and self.publication_end_date:
+        if settings.PAGES_SHOW_END_DATE and self.publication_end_date:
              if self.publication_end_date < datetime.now():
                  return self.EXPIRED

@@ -104,7 +104,7 @@
          """
          get the url of this page, adding parent's slug
          """
-        if settings.PAGE_UNIQUE_SLUG_REQUIRED:
+        if settings.PAGES_UNIQUE_SLUG_REQUIRED:
              url = u'%s/' % self.slug(language)
          else:
              url = u'%s-%d/' % (self.slug(language), self.id)
@@ -117,7 +117,7 @@
          get the slug of the page depending on the given language
          """
          if not language:
-            language = settings.PAGE_DEFAULT_LANGUAGE
+            language = settings.PAGES_DEFAULT_LANGUAGE
          return Content.objects.get_content(self, language, 'slug',
                                             language_fallback=fallback)

@@ -126,21 +126,21 @@
          get the title of the page depending on the given language
          """
          if not language:
-            language = settings.PAGE_DEFAULT_LANGUAGE
+            language = settings.PAGES_DEFAULT_LANGUAGE
          return Content.objects.get_content(self, language, 'title',
                                             language_fallback=fallback)

      def get_template(self):
          """
          get the template of this page if defined or if closer parent if
-        defined or DEFAULT_PAGE_TEMPLATE otherwise
+        defined or PAGES_DEFAULT_TEMPLATE otherwise
          """
          if self.template:
              return self.template
          for p in self.get_ancestors(ascending=True):
              if p.template:
                  return p.template
-        return settings.DEFAULT_PAGE_TEMPLATE
+        return settings.PAGES_DEFAULT_TEMPLATE

      def traductions(self):
          langs = ""
@@ -153,7 +153,7 @@
          Return true if the current user has permission on the page.
          Return the string 'All' if the user has all rights.
          """
-        if not settings.PAGE_PERMISSION:
+        if not settings.PAGES_PERMISSION:
              return True
          else:
              permission =  
PagePermission.objects.get_page_id_list(request.user)
@@ -176,7 +176,7 @@
  except mptt.AlreadyRegistered:
      pass

-if settings.PAGE_PERMISSION:
+if settings.PAGES_PERMISSION:
      class PagePermission(models.Model):
          """
          Page permission object
@@ -215,3 +215,21 @@

      def __unicode__(self):
          return "%s :: %s" % (self.page.slug(), self.body[0:15])
+
+
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes import generic
+
+class Block(models.Model):
+    name = models.CharField(_("plugin_name"), max_length=25, db_index=True)
+    position = models.PositiveSmallIntegerField(_("position"), default=0)
+    language = models.CharField(_("language"), max_length=3, blank=False)
+    page = models.ForeignKey(Page, verbose_name=_("page"))
+    creation_date = models.DateTimeField(_("creation date"),  
editable=False, default=datetime.now)
+
+    content_type = models.ForeignKey(ContentType)
+    object_id = models.TextField()
+    object = generic.GenericForeignKey('content_type', 'object_id')
+
+    class Meta:
+        ordering = ('-creation_date', 'position')

Modified: branches/page-blocks/pages/templates/pages/menu.html
==============================================================================
--- branches/page-blocks/pages/templates/pages/menu.html        (original)
+++ branches/page-blocks/pages/templates/pages/menu.html        Sat Dec 13  
03:24:36 2008
@@ -1,5 +1,5 @@
  {% load pages_tags cache %}
-{% cache PAGE_CONTENT_CACHE_DURATION menu page.id lang current_page.id %}
+{% cache PAGES_CONTENT_CACHE_DURATION menu page.id lang current_page.id %}
  {% if page.status %}
  <li>
  <a href="{% show_absolute_url page %}">{% show_content page "title" %}</a>  
<span style="color:#999">{% ifequal page current_page %}selected{%  
endifequal %}</span>

Modified: branches/page-blocks/pages/templatetags/pages_tags.py
==============================================================================
--- branches/page-blocks/pages/templatetags/pages_tags.py       (original)
+++ branches/page-blocks/pages/templatetags/pages_tags.py       Sat Dec 13  
03:24:36 2008
@@ -3,9 +3,8 @@
  from django.utils.safestring import SafeUnicode, mark_safe
  from django.utils.translation import ugettext_lazy as _
  from django.template import Template, TemplateSyntaxError
-from django.conf import settings as global_settings

-from pages import settings
+from pages.conf import settings
  from pages.models import Content, Page
  from pages.utils import get_language_from_request

@@ -21,7 +20,7 @@
      request = context['request']
      site = request.site
      children = get_page_children_for_site(page, site)
-    PAGE_CONTENT_CACHE_DURATION = settings.PAGE_CONTENT_CACHE_DURATION
+    PAGES_CONTENT_CACHE_DURATION = settings.PAGES_CONTENT_CACHE_DURATION
      lang = get_language_from_request(request)
      if 'current_page' in context:
          current_page = context['current_page']
@@ -87,12 +86,12 @@
              return {'content':''}
      if lang is None:
          lang = get_language_from_request(context['request'])
-    if hasattr(settings, 'PAGE_CONTENT_CACHE_DURATION'):
+    if hasattr(settings, 'PAGES_CONTENT_CACHE_DURATION'):
          key  
= 'content_cache_pid:'+str(page.id)+'_l:'+str(lang)+'_type:'+str(content_type)
          c = cache.get(key)
          if not c:
              c = Content.objects.get_content(page, lang, content_type, True)
-            cache.set(key, c, settings.PAGE_CONTENT_CACHE_DURATION)
+            cache.set(key, c, settings.PAGES_CONTENT_CACHE_DURATION)
      else:
          c = Content.objects.get_content(page, lang, content_type, True)
      if c:
@@ -126,12 +125,12 @@
          return {'content':''}
      if lang is None:
          lang = get_language_from_request(context['request'])
-    if hasattr(settings, 'PAGE_CONTENT_CACHE_DURATION'):
+    if hasattr(settings, 'PAGES_CONTENT_CACHE_DURATION'):
          key  
= 'page_url_pid:'+str(page.id)+'_l:'+str(lang)+'_type:absolute_url'
          url = cache.get(key)
          if not url:
              url = page.get_absolute_url(language=lang)
-            cache.set(key, url, settings.PAGE_CONTENT_CACHE_DURATION)
+            cache.set(key, url, settings.PAGES_CONTENT_CACHE_DURATION)
      else:
          url = page.get_absolute_url(language=lang)
      if url:
@@ -142,7 +141,7 @@

  def show_revisions(context, page, content_type, lang=None):
      """Render the last 10 revisions of a page content with a list"""
-    if not settings.PAGE_CONTENT_REVISION:
+    if not settings.PAGES_CONTENT_REVISION:
          return {'revisions':None}
      revisions = Content.objects.filter(page=page, language=lang,
                                   
type=content_type).order_by('-creation_date')
@@ -301,7 +300,7 @@
                  t = template.Template(content, name=self.name)
                  content = mark_safe(t.render(context))
              except template.TemplateSyntaxError, error:
-                if global_settings.DEBUG:
+                if settings.DEBUG:
                      error = PLACEHOLDER_ERROR % {
                          'name': self.name,
                          'error': error,

Modified: branches/page-blocks/pages/urls.py
==============================================================================
--- branches/page-blocks/pages/urls.py  (original)
+++ branches/page-blocks/pages/urls.py  Sat Dec 13 03:24:36 2008
@@ -1,13 +1,13 @@
  from django.conf.urls.defaults import *
  from pages.views import details
-from pages import settings
+from pages.conf import settings

  urlpatterns = patterns('',
      # Public pages
      url(r'^$', details, name='pages-root'),
  )

-if settings.PAGE_UNIQUE_SLUG_REQUIRED:
+if settings.PAGES_UNIQUE_SLUG_REQUIRED:
      urlpatterns += patterns('',
          url(r'^.*?/?(?P<slug>[-\w]+)/$', details,  
name='pages-details-by-slug'),
      )

Modified: branches/page-blocks/pages/utils.py
==============================================================================
--- branches/page-blocks/pages/utils.py (original)
+++ branches/page-blocks/pages/utils.py Sat Dec 13 03:24:36 2008
@@ -4,7 +4,7 @@
  from django.http import HttpResponse, HttpResponseRedirect
  from django.contrib.sites.models import Site, RequestSite, SITE_CACHE

-from pages import settings
+from pages.conf import settings

  def auto_render(func):
      """Decorator that put automaticaly the template path in the context  
dictionary
@@ -37,18 +37,18 @@
      Gets a valid template from different sources or falls back to the  
default
      template.
      """
-    if settings.PAGE_TEMPLATES is None:
-        return settings.DEFAULT_PAGE_TEMPLATE
+    if settings.PAGES_TEMPLATES is None:
+        return settings.PAGES_DEFAULT_TEMPLATE
      template = request.REQUEST.get('template', None)
      if template is not None and \
-            template in dict(settings.PAGE_TEMPLATES).keys():
+            template in dict(settings.PAGES_TEMPLATES).keys():
          return template
      if obj is not None:
          return obj.get_template()
-    return settings.DEFAULT_PAGE_TEMPLATE
+    return settings.PAGES_DEFAULT_TEMPLATE

  def get_language_in_settings(iso):
-    for language in settings.PAGE_LANGUAGES:
+    for language in settings.PAGES_LANGUAGES:
          if language[0][:2] == iso:
              return iso
      return None
@@ -67,14 +67,14 @@
              if len(languages) > 0:
                  language = languages[0]
      if language is None:
-        language = settings.PAGE_DEFAULT_LANGUAGE
+        language = settings.PAGES_DEFAULT_LANGUAGE
      return language[:2]

  def has_page_add_permission(request, page=None):
      """
      Return true if the current user has permission to add a new page.
      """
-    if not settings.PAGE_PERMISSION:
+    if not settings.PAGES_PERMISSION:
          return True
      else:
          from pages.models import PagePermission

Modified: branches/page-blocks/pages/views.py
==============================================================================
--- branches/page-blocks/pages/views.py (original)
+++ branches/page-blocks/pages/views.py Sat Dec 13 03:24:36 2008
@@ -2,12 +2,12 @@
  from django.shortcuts import get_object_or_404
  from django.contrib.sites.models import SITE_CACHE

-from pages import settings
+from pages.conf import settings
  from pages.models import Page, Content
  from pages.utils import auto_render, get_template_from_request,  
get_language_from_request

  def details(request, page_id=None, slug=None,
-        template_name=settings.DEFAULT_PAGE_TEMPLATE):
+        template_name=settings.PAGES_DEFAULT_TEMPLATE):
      lang = get_language_from_request(request)
      site = request.site
      pages = Page.objects.root(site).order_by("tree_id")

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