Hello community,
here is the log from the commit of package python-django-dbtemplates for openSUSE:Factory checked in at 2012-05-21 07:30:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-dbtemplates (Old)
and /work/SRC/openSUSE:Factory/.python-django-dbtemplates.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-dbtemplates", Maintainer is ""
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-django-dbtemplates/python-django-dbtemplates.changes 2011-09-27 16:07:13.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.python-django-dbtemplates.new/python-django-dbtemplates.changes 2012-05-21 07:30:18.000000000 +0200
@@ -1,0 +2,15 @@
+Mon May 7 22:18:14 UTC 2012 - alexandre@exatati.com.br
+
+- Update to 1.3:
+ * Dropped support for Django < 1.3 **backwards incompatible**
+ * Dropped using versiontools in favor of home made solution.
+ * Added optional support for TinyMCE editor instead of the CodeMirror
+ editor (just enable DBTEMPLATES_USE_TINYMCE).
+ * Fixed compatibility to Django 1.4's handling of the DATABASES
+ setting. Should also respect database routers now.
+ * Fixed an issue of the cache key generation in combination with
+ memcache's inability to stomach spaces.
+ * Moved test runner to use nose_ and a hosted CI project at Travis:
+ http://travis-ci.org/jezdez/django-dbtemplates
+
+-------------------------------------------------------------------
Old:
----
django-dbtemplates-1.2.1.tar.bz2
New:
----
django-dbtemplates-1.3.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-dbtemplates.spec ++++++
--- /var/tmp/diff_new_pack.qoQJtR/_old 2012-05-21 07:30:21.000000000 +0200
+++ /var/tmp/diff_new_pack.qoQJtR/_new 2012-05-21 07:30:21.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-django-dbtemplates
#
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,16 +18,14 @@
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
-%define mod_name django-dbtemplates
-
-Name: python-%{mod_name}
-Version: 1.2.1
+Name: python-django-dbtemplates
+Version: 1.3
Release: 0
Url: http://django-dbtemplates.readthedocs.org/
Summary: Template loader for templates stored in the database
License: BSD-3-Clause
Group: Development/Languages/Python
-Source: %{mod_name}-%{version}.tar.bz2
+Source: django-dbtemplates-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python-devel
BuildRequires: python-versiontools
@@ -49,18 +47,14 @@
command, integrates with Django's caching system and the admin actions.
%prep
-%setup -q -n %{mod_name}-%{version}
+%setup -q -n django-dbtemplates-%{version}
%build
-export CFLAGS="%{optflags}"
python setup.py build
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
-%clean
-rm -rf %{buildroot}
-
%files
%defattr(-,root,root,-)
%{python_sitelib}/*
++++++ django-dbtemplates-1.2.1.tar.bz2 -> django-dbtemplates-1.3.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/AUTHORS new/django-dbtemplates-1.3/AUTHORS
--- old/django-dbtemplates-1.2.1/AUTHORS 2011-08-15 13:24:51.000000000 +0200
+++ new/django-dbtemplates-1.3/AUTHORS 2012-05-07 23:53:05.000000000 +0200
@@ -5,10 +5,14 @@
Arne Brodowski
David Paccoud
Diego Búrigo Zacarão
+Dmitry Falk
Jannis Leidel
+Jure Cuhalev
Jason Mayfield
Kevin Mooney
+Mark Stahler
Matt Dorn
Oliver George
+Selwin Ong
Stephan Peijnik , ANEXIA Internetdienstleistungs GmbH, http://www.anexia.at/
Zhang Kun
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/INSTALL new/django-dbtemplates-1.3/INSTALL
--- old/django-dbtemplates-1.2.1/INSTALL 2010-09-04 14:12:26.000000000 +0200
+++ new/django-dbtemplates-1.3/INSTALL 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-To install it, run the following command inside this directory:
-
- python setup.py install
-
-Or if you'd prefer you can simply place the included ``dbtemplates``
-directory somewhere on your Python path, or symlink to it from
-somewhere on your Python path; this is useful if you're working from a
-Subversion checkout. Since ``dbtemplates`` is registered in the
-Python Package Index you can also run ``easy_install django-dbtemplates``
-or ``pip install django-dbtemplates`` optionally.
-
-Note that this application requires Python 2.3 or later, and a recent
-Subversion checkout of Django. You can obtain Python from
-http://www.python.org/ and Django from http://www.djangoproject.com/.
-
-This install notice was bluntly stolen from James Bennett's registration
-package, http://www.bitbucket.org/ubernostrum/django-registration/
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/LICENSE new/django-dbtemplates-1.3/LICENSE
--- old/django-dbtemplates-1.2.1/LICENSE 2011-08-15 12:48:10.000000000 +0200
+++ new/django-dbtemplates-1.3/LICENSE 2012-05-07 23:53:05.000000000 +0200
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2011, Jannis Leidel and contributors
+Copyright (c) 2007-2012, Jannis Leidel and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/MANIFEST.in new/django-dbtemplates-1.3/MANIFEST.in
--- old/django-dbtemplates-1.2.1/MANIFEST.in 2011-08-15 13:24:51.000000000 +0200
+++ new/django-dbtemplates-1.3/MANIFEST.in 2012-05-07 23:53:05.000000000 +0200
@@ -1,4 +1,3 @@
-include INSTALL
include LICENSE
include AUTHORS
include README.rst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/PKG-INFO new/django-dbtemplates-1.3/PKG-INFO
--- old/django-dbtemplates-1.2.1/PKG-INFO 2011-09-07 12:08:24.000000000 +0200
+++ new/django-dbtemplates-1.3/PKG-INFO 2012-05-07 23:54:19.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: django-dbtemplates
-Version: 1.2.1
+Version: 1.3
Summary: Template loader for templates stored in the database
Home-page: http://django-dbtemplates.readthedocs.org/
Author: Jannis Leidel
@@ -9,6 +9,10 @@
Description: django-dbtemplates
==================
+ .. image:: https://secure.travis-ci.org/jezdez/django-dbtemplates.png?branch=develop
+ :alt: Build Status
+ :target: http://travis-ci.org/jezdez/django-dbtemplates
+
``dbtemplates`` is a Django app that consists of two parts:
1. It allows you to store templates in your database
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/README.rst new/django-dbtemplates-1.3/README.rst
--- old/django-dbtemplates-1.2.1/README.rst 2011-07-08 15:01:18.000000000 +0200
+++ new/django-dbtemplates-1.3/README.rst 2012-05-07 23:53:05.000000000 +0200
@@ -1,6 +1,10 @@
django-dbtemplates
==================
+.. image:: https://secure.travis-ci.org/jezdez/django-dbtemplates.png?branch=develop
+ :alt: Build Status
+ :target: http://travis-ci.org/jezdez/django-dbtemplates
+
``dbtemplates`` is a Django app that consists of two parts:
1. It allows you to store templates in your database
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/__init__.py new/django-dbtemplates-1.3/dbtemplates/__init__.py
--- old/django-dbtemplates-1.2.1/dbtemplates/__init__.py 2011-09-06 14:53:56.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/__init__.py 2012-05-07 23:53:19.000000000 +0200
@@ -1,2 +1,2 @@
-# following PEP 386, versiontools will pick it up
-__version__ = (1, 2, 1, "final", 0)
+# following PEP 386
+__version__ = "1.3"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/admin.py new/django-dbtemplates-1.3/dbtemplates/admin.py
--- old/django-dbtemplates-1.2.1/dbtemplates/admin.py 2011-08-15 13:24:52.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/admin.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,6 +1,7 @@
import posixpath
from django import forms
from django.contrib import admin
+from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import ungettext, ugettext_lazy as _
from django.utils.safestring import mark_safe
@@ -14,7 +15,7 @@
if settings.DBTEMPLATES_USE_REVERSION:
from reversion.admin import VersionAdmin as TemplateModelAdmin
else:
- from django.contrib.admin import ModelAdmin as TemplateModelAdmin
+ from django.contrib.admin import ModelAdmin as TemplateModelAdmin # noqa
class CodeMirrorTextArea(forms.Textarea):
@@ -59,6 +60,14 @@
else:
content_help_text = ""
+if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE:
+ raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE "
+ "with dbtemplates, not both. Please disable one of them.")
+
+if settings.DBTEMPLATES_USE_TINYMCE:
+ from tinymce.widgets import AdminTinyMCE
+ TemplateContentTextArea = AdminTinyMCE
+
class TemplateAdminForm(forms.ModelForm):
"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/conf.py new/django-dbtemplates-1.3/dbtemplates/conf.py
--- old/django-dbtemplates-1.2.1/dbtemplates/conf.py 2011-09-05 11:07:30.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/conf.py 2012-05-07 23:53:05.000000000 +0200
@@ -9,6 +9,7 @@
class DbTemplatesConf(AppConf):
USE_CODEMIRROR = False
USE_REVERSION = False
+ USE_TINYMCE = False
ADD_DEFAULT_SITE = True
AUTO_POPULATE_CONTENT = True
MEDIA_PREFIX = None
@@ -40,3 +41,9 @@
raise ImproperlyConfigured("Please add 'reversion' to your "
"INSTALLED_APPS setting to make use of it in dbtemplates.")
return value
+
+ def configure_use_tinymce(self, value):
+ if value and 'tinymce' not in settings.INSTALLED_APPS:
+ raise ImproperlyConfigured("Please add 'tinymce' to your "
+ "INSTALLED_APPS setting to make use of it in dbtemplates.")
+ return value
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/loader.py new/django-dbtemplates-1.3/dbtemplates/loader.py
--- old/django-dbtemplates-1.2.1/dbtemplates/loader.py 2011-08-15 13:24:52.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/loader.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,7 +1,7 @@
from django.contrib.sites.models import Site
+from django.db import router
from django.template import TemplateDoesNotExist
-from dbtemplates.conf import settings
from dbtemplates.models import Template
from dbtemplates.utils.cache import (cache, get_cache_key,
set_and_return, get_cache_notfound_key)
@@ -19,6 +19,12 @@
"""
is_usable = True
+ def load_and_store_template(self, template_name, cache_key, site, **params):
+ template = Template.objects.get(name__exact=template_name, **params)
+ db = router.db_for_read(Template, instance=template)
+ display_name = 'dbtemplates:%s:%s:%s' % (db, template_name, site.domain)
+ return set_and_return(cache_key, template.content, display_name)
+
def load_template_source(self, template_name, template_dirs=None):
# The logic should work like this:
# * Try to find the template in the cache. If found, return it.
@@ -33,8 +39,6 @@
# in the cache indicating that queries failed, with the current
# timestamp.
site = Site.objects.get_current()
- display_name = 'dbtemplates:%s:%s:%s' % (settings.DATABASE_ENGINE,
- template_name, site.domain)
cache_key = get_cache_key(template_name)
if cache:
try:
@@ -57,14 +61,13 @@
# Not marked as not-found, move on...
try:
- template = Template.objects.get(name__exact=template_name,
- sites__in=[site.id])
- return set_and_return(cache_key, template.content, display_name)
+ return self.load_and_store_template(template_name, cache_key,
+ site, sites__in=[site.id])
except (Template.MultipleObjectsReturned, Template.DoesNotExist):
try:
- template = Template.objects.get(name__exact=template_name)
- return set_and_return(cache_key, template.content, display_name)
- except Template.DoesNotExist:
+ return self.load_and_store_template(template_name, cache_key,
+ site, sites__in=[])
+ except (Template.MultipleObjectsReturned, Template.DoesNotExist):
pass
# Mark as not-found in cache.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/management/commands/check_template_syntax.py new/django-dbtemplates-1.3/dbtemplates/management/commands/check_template_syntax.py
--- old/django-dbtemplates-1.2.1/dbtemplates/management/commands/check_template_syntax.py 2011-08-15 13:24:52.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/management/commands/check_template_syntax.py 2012-05-07 23:53:05.000000000 +0200
@@ -3,6 +3,7 @@
from dbtemplates.models import Template
from dbtemplates.utils.template import check_template_syntax
+
class Command(NoArgsCommand):
help = "Ensures templates stored in the database don't have syntax errors."
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/management/commands/sync_templates.py new/django-dbtemplates-1.3/dbtemplates/management/commands/sync_templates.py
--- old/django-dbtemplates-1.2.1/dbtemplates/management/commands/sync_templates.py 2011-07-06 21:28:40.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/management/commands/sync_templates.py 2012-05-07 23:53:05.000000000 +0200
@@ -11,6 +11,7 @@
ALWAYS_ASK, FILES_TO_DATABASE, DATABASE_TO_FILES = ('0', '1', '2')
+
class Command(NoArgsCommand):
help = "Syncs file system templates with the database bidirectionally."
option_list = NoArgsCommand.option_list + (
@@ -89,7 +90,8 @@
path, t.__repr__()))
else:
confirm = overwrite
- if confirm in ('', FILES_TO_DATABASE, DATABASE_TO_FILES):
+ if confirm in ('', FILES_TO_DATABASE,
+ DATABASE_TO_FILES):
if confirm == FILES_TO_DATABASE:
t.content = codecs.open(path, 'r').read()
t.save()
@@ -101,8 +103,8 @@
raise CommandError(
u"Couldn't delete %s" % path)
elif confirm == DATABASE_TO_FILES:
+ f = codecs.open(path, 'w', 'utf-8')
try:
- f = codecs.open(path, 'w')
f.write(t.content)
finally:
f.close()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/migrations/0001_initial.py new/django-dbtemplates-1.3/dbtemplates/migrations/0001_initial.py
--- old/django-dbtemplates-1.2.1/dbtemplates/migrations/0001_initial.py 2011-07-06 21:28:40.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/migrations/0001_initial.py 2012-05-07 23:53:05.000000000 +0200
@@ -4,10 +4,11 @@
from south.v2 import SchemaMigration
from django.db import models
+
class Migration(SchemaMigration):
def forwards(self, orm):
-
+
# Adding model 'Template'
db.create_table('django_template', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
@@ -26,16 +27,13 @@
))
db.create_unique('django_template_sites', ['template_id', 'site_id'])
-
def backwards(self, orm):
-
# Deleting model 'Template'
db.delete_table('django_template')
# Removing M2M table for field sites on 'Template'
db.delete_table('django_template_sites')
-
models = {
'dbtemplates.template': {
'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/migrations/0002_auto__del_unique_template_name.py new/django-dbtemplates-1.3/dbtemplates/migrations/0002_auto__del_unique_template_name.py
--- old/django-dbtemplates-1.2.1/dbtemplates/migrations/0002_auto__del_unique_template_name.py 2011-07-06 21:28:40.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/migrations/0002_auto__del_unique_template_name.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,23 +1,18 @@
# encoding: utf-8
-import datetime
from south.db import db
from south.v2 import SchemaMigration
-from django.db import models
+
class Migration(SchemaMigration):
def forwards(self, orm):
-
# Removing unique constraint on 'Template', fields ['name']
db.delete_unique('django_template', ['name'])
-
def backwards(self, orm):
-
# Adding unique constraint on 'Template', fields ['name']
db.create_unique('django_template', ['name'])
-
models = {
'dbtemplates.template': {
'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/models.py new/django-dbtemplates-1.3/dbtemplates/models.py
--- old/django-dbtemplates-1.2.1/dbtemplates/models.py 2011-09-05 10:53:23.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/models.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from datetime import datetime
-
from django.db import models
from django.db.models import signals
from django.template import TemplateDoesNotExist
@@ -13,6 +11,12 @@
from dbtemplates.utils.cache import add_template_to_cache, remove_cached_template
from dbtemplates.utils.template import get_template_source
+try:
+ from django.utils.timezone import now
+except ImportError:
+ from datetime import datetime
+ now = datetime.now
+
class Template(models.Model):
"""
@@ -25,9 +29,9 @@
sites = models.ManyToManyField(Site, verbose_name=_(u'sites'),
blank=True, null=True)
creation_date = models.DateTimeField(_('creation date'),
- default=datetime.now)
+ default=now)
last_changed = models.DateTimeField(_('last changed'),
- default=datetime.now)
+ default=now)
objects = models.Manager()
on_site = CurrentSiteManager('sites')
@@ -56,7 +60,7 @@
pass
def save(self, *args, **kwargs):
- self.last_changed = datetime.now()
+ self.last_changed = now()
# If content is empty look for a template with the given name and
# populate the template instance with its content.
if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT and not self.content:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/test_cases.py new/django-dbtemplates-1.3/dbtemplates/test_cases.py
--- old/django-dbtemplates-1.2.1/dbtemplates/test_cases.py 1970-01-01 01:00:00.000000000 +0100
+++ new/django-dbtemplates-1.3/dbtemplates/test_cases.py 2012-05-07 23:53:05.000000000 +0200
@@ -0,0 +1,147 @@
+import codecs
+import os
+import shutil
+import tempfile
+
+from django.conf import settings as django_settings
+from django.core.cache.backends.base import BaseCache
+from django.core.management import call_command
+from django.template import loader, Context, TemplateDoesNotExist
+from django.test import TestCase
+
+from django.contrib.sites.models import Site
+
+from dbtemplates.conf import settings
+from dbtemplates.models import Template
+from dbtemplates.utils.cache import get_cache_backend, get_cache_key
+from dbtemplates.utils.template import (get_template_source,
+ check_template_syntax)
+from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE,
+ DATABASE_TO_FILES)
+
+
+class DbTemplatesTestCase(TestCase):
+ def setUp(self):
+ self.old_template_loaders = settings.TEMPLATE_LOADERS
+ if 'dbtemplates.loader.Loader' not in settings.TEMPLATE_LOADERS:
+ loader.template_source_loaders = None
+ settings.TEMPLATE_LOADERS = (list(settings.TEMPLATE_LOADERS) +
+ ['dbtemplates.loader.Loader'])
+
+ self.site1, created1 = Site.objects.get_or_create(
+ domain="example.com", name="example.com")
+ self.site2, created2 = Site.objects.get_or_create(
+ domain="example.org", name="example.org")
+ self.t1, _ = Template.objects.get_or_create(
+ name='base.html', content='base')
+ self.t2, _ = Template.objects.get_or_create(
+ name='sub.html', content='sub')
+ self.t2.sites.add(self.site2)
+
+ def tearDown(self):
+ loader.template_source_loaders = None
+ settings.TEMPLATE_LOADERS = self.old_template_loaders
+
+ def test_basiscs(self):
+ self.assertEqual(list(self.t1.sites.all()), [self.site1])
+ self.assertTrue("base" in self.t1.content)
+ self.assertEqual(list(Template.objects.filter(sites=self.site1)),
+ [self.t1, self.t2])
+ self.assertEqual(list(self.t2.sites.all()), [self.site1, self.site2])
+
+ def test_empty_sites(self):
+ old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE
+ try:
+ settings.DBTEMPLATES_ADD_DEFAULT_SITE = False
+ self.t3 = Template.objects.create(
+ name='footer.html', content='footer')
+ self.assertEqual(list(self.t3.sites.all()), [])
+ finally:
+ settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site
+
+ def test_load_templates_sites(self):
+ old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE
+ old_site_id = django_settings.SITE_ID
+ try:
+ settings.DBTEMPLATES_ADD_DEFAULT_SITE = False
+ t_site1 = Template.objects.create(
+ name='copyright.html', content='(c) example.com')
+ t_site1.sites.add(self.site1)
+ t_site2 = Template.objects.create(
+ name='copyright.html', content='(c) example.org')
+ t_site2.sites.add(self.site2)
+
+ django_settings.SITE_ID = Site.objects.create(
+ domain="example.net", name="example.net").id
+ Site.objects.clear_cache()
+
+ self.assertRaises(TemplateDoesNotExist,
+ loader.get_template, "copyright.html")
+ finally:
+ django_settings.SITE_ID = old_site_id
+ settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site
+
+ def test_load_templates(self):
+ result = loader.get_template("base.html").render(Context({}))
+ self.assertEqual(result, 'base')
+ result2 = loader.get_template("sub.html").render(Context({}))
+ self.assertEqual(result2, 'sub')
+
+ def test_error_templates_creation(self):
+ call_command('create_error_templates', force=True, verbosity=0)
+ self.assertEqual(list(Template.objects.filter(sites=self.site1)),
+ list(Template.objects.filter()))
+ self.assertTrue(Template.objects.filter(name='404.html').exists())
+
+ def test_automatic_sync(self):
+ admin_base_template = get_template_source('admin/base.html')
+ template = Template.objects.create(name='admin/base.html')
+ self.assertEqual(admin_base_template, template.content)
+
+ def test_sync_templates(self):
+ old_template_dirs = settings.TEMPLATE_DIRS
+ temp_template_dir = tempfile.mkdtemp('dbtemplates')
+ temp_template_path = os.path.join(temp_template_dir, 'temp_test.html')
+ temp_template = codecs.open(temp_template_path, 'w')
+ try:
+ temp_template.write('temp test')
+ settings.TEMPLATE_DIRS = (temp_template_dir,)
+ self.assertFalse(
+ Template.objects.filter(name='temp_test.html').exists())
+ call_command('sync_templates',
+ force=True, verbosity=0, overwrite=FILES_TO_DATABASE)
+ self.assertTrue(
+ Template.objects.filter(name='temp_test.html').exists())
+
+ t = Template.objects.get(name='temp_test.html')
+ t.content = 'temp test modified'
+ t.save()
+ call_command('sync_templates',
+ force=True, verbosity=0, overwrite=DATABASE_TO_FILES)
+ self.assertTrue(
+ 'modified' in codecs.open(temp_template_path).read())
+
+ call_command('sync_templates', force=True, verbosity=0,
+ delete=True, overwrite=DATABASE_TO_FILES)
+ self.assertTrue(os.path.exists(temp_template_path))
+ self.assertFalse(
+ Template.objects.filter(name='temp_test.html').exists())
+ finally:
+ temp_template.close()
+ settings.TEMPLATE_DIRS = old_template_dirs
+ shutil.rmtree(temp_template_dir)
+
+ def test_get_cache(self):
+ self.assertTrue(isinstance(get_cache_backend(), BaseCache))
+
+ def test_check_template_syntax(self):
+ bad_template, _ = Template.objects.get_or_create(
+ name='bad.html', content='{% if foo %}Bar')
+ good_template, _ = Template.objects.get_or_create(
+ name='good.html', content='{% if foo %}Bar{% endif %}')
+ self.assertFalse(check_template_syntax(bad_template)[0])
+ self.assertTrue(check_template_syntax(good_template)[0])
+
+ def test_get_cache_name(self):
+ self.assertEqual(get_cache_key('name with spaces'),
+ 'dbtemplates::name-with-spaces::1')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/test_settings.py new/django-dbtemplates-1.3/dbtemplates/test_settings.py
--- old/django-dbtemplates-1.2.1/dbtemplates/test_settings.py 2011-09-05 11:24:16.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/test_settings.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,14 +1,27 @@
DBTEMPLATES_CACHE_BACKEND = 'dummy://'
DATABASE_ENGINE = 'sqlite3'
+# SQLite does not support removing unique constraints (see #28)
+SOUTH_TESTS_MIGRATE = False
SITE_ID = 1
+SECRET_KEY = 'something-something'
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ }
+}
+
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sites',
'django.contrib.admin',
+ 'django.contrib.auth',
'dbtemplates',
+ 'django_nose',
]
TEMPLATE_LOADERS = (
@@ -16,3 +29,5 @@
'django.template.loaders.app_directories.Loader',
'dbtemplates.loader.Loader',
)
+
+TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/tests.py new/django-dbtemplates-1.3/dbtemplates/tests.py
--- old/django-dbtemplates-1.2.1/dbtemplates/tests.py 2011-09-05 12:28:20.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/tests.py 1970-01-01 01:00:00.000000000 +0100
@@ -1,107 +0,0 @@
-from __future__ import with_statement
-import codecs
-import os
-import shutil
-import tempfile
-
-from django.core.cache.backends.base import BaseCache
-from django.core.management import call_command
-from django.template import loader, Context
-from django.test import TestCase
-
-from django.contrib.sites.models import Site
-
-from dbtemplates.conf import settings
-from dbtemplates.models import Template
-from dbtemplates.utils.cache import get_cache_backend
-from dbtemplates.utils.template import (get_template_source,
- check_template_syntax)
-from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE,
- DATABASE_TO_FILES)
-
-class DbTemplatesTestCase(TestCase):
- def setUp(self):
- self.site1, created1 = Site.objects.get_or_create(
- domain="example.com", name="example.com")
- self.site2, created2 = Site.objects.get_or_create(
- domain="example.org", name="example.org")
- self.t1, _ = Template.objects.get_or_create(
- name='base.html', content='base')
- self.t2, _ = Template.objects.get_or_create(
- name='sub.html', content='sub')
- self.t2.sites.add(self.site2)
-
- def test_basiscs(self):
- self.assertEqual(list(self.t1.sites.all()), [self.site1])
- self.assertTrue("base" in self.t1.content)
- self.assertEqual(list(Template.objects.filter(sites=self.site1)),
- [self.t1, self.t2])
- self.assertEqual(list(self.t2.sites.all()), [self.site1, self.site2])
-
- def test_empty_sites(self):
- old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE
- try:
- settings.DBTEMPLATES_ADD_DEFAULT_SITE = False
- self.t3 = Template.objects.create(
- name='footer.html', content='footer')
- self.assertEqual(list(self.t3.sites.all()), [])
- finally:
- settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site
-
- def test_load_templates(self):
- result = loader.get_template("base.html").render(Context({}))
- self.assertEqual(result, 'base')
- result2 = loader.get_template("sub.html").render(Context({}))
- self.assertEqual(result2, 'sub')
-
- def test_error_templates_creation(self):
- call_command('create_error_templates', force=True, verbosity=0)
- self.assertEqual(list(Template.objects.filter(sites=self.site1)),
- list(Template.objects.filter()))
- self.assertTrue(Template.objects.filter(name='404.html').exists())
-
- def test_automatic_sync(self):
- admin_base_template = get_template_source('admin/base.html')
- template = Template.objects.create(name='admin/base.html')
- self.assertEqual(admin_base_template, template.content)
-
- def test_sync_templates(self):
- old_template_dirs = settings.TEMPLATE_DIRS
- temp_template_dir = tempfile.mkdtemp('dbtemplates')
- last_path_part = temp_template_dir.split('/')[-1]
- temp_template_path = os.path.join(temp_template_dir, 'temp_test.html')
- temp_template = codecs.open(temp_template_path, 'w')
- try:
- temp_template.write('temp test')
- settings.TEMPLATE_DIRS = (temp_template_dir,)
- self.assertFalse(Template.objects.filter(name='temp_test.html').exists())
- call_command('sync_templates',
- force=True, verbosity=0, overwrite=FILES_TO_DATABASE)
- self.assertTrue(Template.objects.filter(name='temp_test.html').exists())
-
- t = Template.objects.get(name='temp_test.html')
- t.content = 'temp test modified'
- t.save()
- call_command('sync_templates',
- force=True, verbosity=0, overwrite=DATABASE_TO_FILES)
- self.assertTrue('modified' in codecs.open(temp_template_path).read())
-
- call_command('sync_templates',
- force=True, verbosity=0, delete=True, overwrite=DATABASE_TO_FILES)
- self.assertTrue(os.path.exists(temp_template_path))
- self.assertFalse(Template.objects.filter(name='temp_test.html').exists())
- finally:
- temp_template.close()
- settings.TEMPLATE_DIRS = old_template_dirs
- shutil.rmtree(temp_template_dir)
-
- def test_get_cache(self):
- self.assertTrue(isinstance(get_cache_backend(), BaseCache))
-
- def test_check_template_syntax(self):
- bad_template, _ = Template.objects.get_or_create(
- name='bad.html', content='{% if foo %}Bar')
- good_template, _ = Template.objects.get_or_create(
- name='good.html', content='{% if foo %}Bar{% endif %}')
- self.assertFalse(check_template_syntax(bad_template)[0])
- self.assertTrue(check_template_syntax(good_template)[0])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/utils/cache.py new/django-dbtemplates-1.3/dbtemplates/utils/cache.py
--- old/django-dbtemplates-1.2.1/dbtemplates/utils/cache.py 2011-08-15 13:24:52.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/utils/cache.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,6 +1,7 @@
from django.core.cache import get_cache
from django.contrib.sites.models import Site
+from django.template.defaultfilters import slugify
from dbtemplates.conf import settings
@@ -13,7 +14,7 @@
def get_cache_key(name):
current_site = Site.objects.get_current()
- return 'dbtemplates::%s::%s' % (name, current_site.pk)
+ return 'dbtemplates::%s::%s' % (slugify(name), current_site.pk)
def get_cache_notfound_key(name):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/dbtemplates/utils/template.py new/django-dbtemplates-1.3/dbtemplates/utils/template.py
--- old/django-dbtemplates-1.2.1/dbtemplates/utils/template.py 2011-08-15 13:24:52.000000000 +0200
+++ new/django-dbtemplates-1.3/dbtemplates/utils/template.py 2012-05-07 23:53:05.000000000 +0200
@@ -8,13 +8,11 @@
from django.template.loader import template_source_loaders
if template_source_loaders is None:
try:
- from django.template.loader import (
- find_template as finder_func)
+ from django.template.loader import find_template as finder
except ImportError:
- from django.template.loader import (
- find_template_source as finder_func)
+ from django.template.loader import find_template_source as finder # noqa
try:
- source, name = finder_func('test')
+ source, name = finder('test')
except TemplateDoesNotExist:
pass
from django.template.loader import template_source_loaders
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/django_dbtemplates.egg-info/PKG-INFO new/django-dbtemplates-1.3/django_dbtemplates.egg-info/PKG-INFO
--- old/django-dbtemplates-1.2.1/django_dbtemplates.egg-info/PKG-INFO 2011-09-07 12:08:24.000000000 +0200
+++ new/django-dbtemplates-1.3/django_dbtemplates.egg-info/PKG-INFO 2012-05-07 23:54:19.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: django-dbtemplates
-Version: 1.2.1
+Version: 1.3
Summary: Template loader for templates stored in the database
Home-page: http://django-dbtemplates.readthedocs.org/
Author: Jannis Leidel
@@ -9,6 +9,10 @@
Description: django-dbtemplates
==================
+ .. image:: https://secure.travis-ci.org/jezdez/django-dbtemplates.png?branch=develop
+ :alt: Build Status
+ :target: http://travis-ci.org/jezdez/django-dbtemplates
+
``dbtemplates`` is a Django app that consists of two parts:
1. It allows you to store templates in your database
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/django_dbtemplates.egg-info/SOURCES.txt new/django-dbtemplates-1.3/django_dbtemplates.egg-info/SOURCES.txt
--- old/django-dbtemplates-1.2.1/django_dbtemplates.egg-info/SOURCES.txt 2011-09-07 12:08:24.000000000 +0200
+++ new/django-dbtemplates-1.3/django_dbtemplates.egg-info/SOURCES.txt 2012-05-07 23:54:19.000000000 +0200
@@ -1,5 +1,4 @@
AUTHORS
-INSTALL
LICENSE
MANIFEST.in
README.rst
@@ -10,8 +9,8 @@
dbtemplates/conf.py
dbtemplates/loader.py
dbtemplates/models.py
+dbtemplates/test_cases.py
dbtemplates/test_settings.py
-dbtemplates/tests.py
dbtemplates/locale/da/LC_MESSAGES/django.mo
dbtemplates/locale/da/LC_MESSAGES/django.po
dbtemplates/locale/de/LC_MESSAGES/django.mo
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/docs/changelog.txt new/django-dbtemplates-1.3/docs/changelog.txt
--- old/django-dbtemplates-1.2.1/docs/changelog.txt 2011-09-07 12:04:57.000000000 +0200
+++ new/django-dbtemplates-1.3/docs/changelog.txt 2012-05-07 23:53:05.000000000 +0200
@@ -1,6 +1,28 @@
Changelog
=========
+v1.3 (2012-05-07)
+-----------------
+
+* Dropped support for Django < 1.3 **backwards incompatible**
+
+* Dropped using versiontools in favor of home made solution.
+
+* Added optional support for TinyMCE editor instead of the CodeMirror
+ editor (just enable ``DBTEMPLATES_USE_TINYMCE``).
+
+* Fixed compatibility to Django 1.4's handling of the ``DATABASES``
+ setting. Should also respect database routers now.
+
+* Fixed an issue of the cache key generation in combination with
+ memcache's inability to stomach spaces.
+
+* Moved test runner to use nose_ and a hosted CI project at Travis_:
+ http://travis-ci.org/jezdez/django-dbtemplates
+
+.. _nose: http://nose.rtfd.org/
+.. _Travis: http://travis-ci.org
+
v1.2.1 (2011-09-07)
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/docs/overview.txt new/django-dbtemplates-1.3/docs/overview.txt
--- old/django-dbtemplates-1.2.1/docs/overview.txt 2011-07-08 15:01:18.000000000 +0200
+++ new/django-dbtemplates-1.3/docs/overview.txt 2012-05-07 23:53:05.000000000 +0200
@@ -2,7 +2,7 @@
=====
1. Get the source from the `Git repository`_ or install it from the
- Python Package Index by running ``pip django-dbtemplates``.
+ Python Package Index by running ``pip install django-dbtemplates``.
2. Follow the instructions in the INSTALL file
3. Edit the settings.py of your Django site:
@@ -35,6 +35,11 @@
'dbtemplates.loader.Loader',
)
+ Order of TEMPLATE_LOADERS is important. In the former example, templates from database
+ will be used as a fallback (ie. when template does not exists in other locations).
+ If you want template from database to be used to override templates in other locations,
+ put ``dbtemplates.loader.Loader`` at beginning of ``TEMPLATE_LOADERS`` settting.
+
4. Sync your database ``python manage.py syncdb``
5. Restart your Django server
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/docs/settings.txt new/django-dbtemplates-1.3/docs/settings.txt
--- old/django-dbtemplates-1.2.1/docs/settings.txt 2011-04-11 23:31:14.000000000 +0200
+++ new/django-dbtemplates-1.3/docs/settings.txt 2012-05-07 23:53:05.000000000 +0200
@@ -4,8 +4,8 @@
``DBTEMPLATES_ADD_DEFAULT_SITE``
--------------------------------
-``dbtemplates`` adds the current site (``settings.SITE_ID``) to the database
-template when it is created by default. You can disable this feature by
+``dbtemplates`` adds the current site (``settings.SITE_ID``) to the database
+template when it is created by default. You can disable this feature by
setting ``DBTEMPLATES_ADD_DEFAULT_SITE`` to ``False``.
``DBTEMPLATES_AUTO_POPULATE_CONTENT``
@@ -28,6 +28,14 @@
A boolean, if enabled triggers the use of the CodeMirror based editor.
Set to ``False`` by default.
+``DBTEMPLATES_USE_TINYMCE``
+---------------------------
+
+.. versionadded:: 1.3
+
+A boolean, if enabled triggers the use of the TinyMCE based editor.
+Set to ``False`` by default.
+
``DBTEMPLATES_USE_REVERSION``
-----------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/setup.cfg new/django-dbtemplates-1.3/setup.cfg
--- old/django-dbtemplates-1.2.1/setup.cfg 2011-09-07 12:08:24.000000000 +0200
+++ new/django-dbtemplates-1.3/setup.cfg 2012-05-07 23:54:19.000000000 +0200
@@ -14,3 +14,7 @@
[upload_sphinx]
upload-dir = docs/_build/html
+[nosetests]
+with-coverage = 1
+cover-package = dbtemplates
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-dbtemplates-1.2.1/setup.py new/django-dbtemplates-1.3/setup.py
--- old/django-dbtemplates-1.2.1/setup.py 2011-09-06 14:54:08.000000000 +0200
+++ new/django-dbtemplates-1.3/setup.py 2012-05-07 23:53:05.000000000 +0200
@@ -1,20 +1,33 @@
+import os
+import re
import codecs
-from os import path
from setuptools import setup, find_packages
-read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
+
+def read(*parts):
+ return codecs.open(os.path.join(os.path.dirname(__file__), *parts)).read()
+
+
+def find_version(*file_paths):
+ version_file = read(*file_paths)
+ version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
+ version_file, re.M)
+ if version_match:
+ return version_match.group(1)
+ raise RuntimeError("Unable to find version string.")
+
setup(
name='django-dbtemplates',
- version=':versiontools:dbtemplates:',
+ version=find_version('dbtemplates', '__init__.py'),
description='Template loader for templates stored in the database',
- long_description=read(path.join(path.dirname(__file__), 'README.rst')),
+ long_description=read('README.rst'),
author='Jannis Leidel',
author_email='jannis@leidel.info',
url='http://django-dbtemplates.readthedocs.org/',
packages=find_packages(exclude=['example']),
zip_safe=False,
- package_data = {
+ package_data={
'dbtemplates': [
'locale/*/LC_MESSAGES/*',
'static/dbtemplates/css/*.css',
@@ -35,5 +48,4 @@
'Framework :: Django',
],
install_requires=['django-appconf >= 0.4'],
- setup_requires=['versiontools >= 1.5'],
)
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org