From 1291324593ad316eb77df0c722cd7c659c57825a Mon Sep 17 00:00:00 2001
From: Antonio Cavedoni
Date: Fri, 16 Feb 2007 14:56:33 +0100
Subject: [PATCH 1/5] Removed test_django_date_type test case if Django is not
available
---
tests/test_filter_django.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_filter_django.py b/tests/test_filter_django.py
index c61f11b..45aab45 100644
--- a/tests/test_filter_django.py
+++ b/tests/test_filter_django.py
@@ -31,4 +31,5 @@ try:
except ImportError:
logger.warn("Django is not available => can't test django filters")
del DjangoFilterTests.test_django_filter
+ del DjangoFilterTests.test_django_date_type
del DjangoFilterTests.test_django_item_title
From 9fc1032050f6de15029de5fc82ac2cf703e27bbc Mon Sep 17 00:00:00 2001
From: Antonio Cavedoni
Date: Fri, 16 Feb 2007 15:08:39 +0100
Subject: [PATCH 2/5] Removed hardcoded test case deletion if the django module
is not installed, switched to dynamic attr removal
---
tests/test_filter_django.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/test_filter_django.py b/tests/test_filter_django.py
index 45aab45..af4f46e 100644
--- a/tests/test_filter_django.py
+++ b/tests/test_filter_django.py
@@ -30,6 +30,5 @@ try:
from django.conf import settings
except ImportError:
logger.warn("Django is not available => can't test django filters")
- del DjangoFilterTests.test_django_filter
- del DjangoFilterTests.test_django_date_type
- del DjangoFilterTests.test_django_item_title
+ for method in dir(DjangoFilterTests):
+ if method.startswith('test_'): delattr(DjangoFilterTests,method)
From a590d13fe8d9a9e39d64dd6ee5913f6a264ba12f Mon Sep 17 00:00:00 2001
From: Antonio Cavedoni
Date: Tue, 20 Feb 2007 15:46:32 +0100
Subject: [PATCH 3/5] Added note on pywin32 dependency for Windows, added
pointer to Django templates documentation, added check for WindowsError while
trying to load sed on Win
---
docs/index.html | 1 +
docs/installation.html | 9 +++++++++
tests/test_filters.py | 14 ++++++++++----
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/docs/index.html b/docs/index.html
index 3ebc8c2..a60c29f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -38,6 +38,7 @@
httplib2
XSLT
sed
+Django templates
Credits and License
diff --git a/docs/installation.html b/docs/installation.html
index 6a668d1..d8edf98 100644
--- a/docs/installation.html
+++ b/docs/installation.html
@@ -107,6 +107,15 @@ not yet ported to the newer python so Venus will be less featureful.
sudo apt-get install bzr python2.4-librdf
+Windows instructions
+
+
+ htmltmpl templates (and Django too, since it currently piggybacks on
+ the htmltmpl implementation) on Windows require
+ the pywin32
+ module.
+
+
Python 2.2 instructions
If you are running Python 2.2, you may also need to install pyxml. If the
diff --git a/tests/test_filters.py b/tests/test_filters.py
index fc61e47..58177fc 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -111,11 +111,17 @@ class FilterTests(unittest.TestCase):
try:
from subprocess import Popen, PIPE
- sed=Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
- sed.communicate()
- if sed.returncode != 0:
+ try:
+ sed = Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
+ sed.communicate()
+ if sed.returncode != 0:
+ _no_sed = True
+ except WindowsError:
+ _no_sed = True
+
+ if _no_sed:
logger.warn("sed is not available => can't test stripAd_yahoo")
- del FilterTests.test_stripAd_yahoo
+ del FilterTests.test_stripAd_yahoo
try:
import libxml2
From fb29d39501422ff9ca821e2158f4bde1fb785d8d Mon Sep 17 00:00:00 2001
From: Antonio Cavedoni
Date: Thu, 1 Mar 2007 20:37:02 +0100
Subject: [PATCH 4/5] Added, tested and documented the new Config variable
available in the Django templates/filters: makes it easy to access .ini
configuration items from one's templates
---
docs/templates.html | 5 +++++
planet/shell/dj.py | 1 +
tests/data/filter/django/config.html.dj | 1 +
tests/test_filter_django.py | 9 +++++++++
4 files changed, 16 insertions(+)
create mode 100644 tests/data/filter/django/config.html.dj
diff --git a/docs/templates.html b/docs/templates.html
index 748c956..1eb9d7a 100644
--- a/docs/templates.html
+++ b/docs/templates.html
@@ -115,6 +115,11 @@ Item.
able to iterate through them.
+
+ You also have access to the Config
dictionary, which contains
+ the Venus configuration variables from your .ini
file.
+
+
If you lose your way and want to introspect all the variable in the
context, there's the useful {% debug %}
template tag.
diff --git a/planet/shell/dj.py b/planet/shell/dj.py
index 7724902..2ce316a 100644
--- a/planet/shell/dj.py
+++ b/planet/shell/dj.py
@@ -33,6 +33,7 @@ def run(script, doc, output_file=None, options={}):
# datatype converters
context = Context()
context.update(tmpl.template_info(doc))
+ context['Config'] = config.planet_options()
t = get_template(script)
if output_file:
diff --git a/tests/data/filter/django/config.html.dj b/tests/data/filter/django/config.html.dj
new file mode 100644
index 0000000..25fde8f
--- /dev/null
+++ b/tests/data/filter/django/config.html.dj
@@ -0,0 +1 @@
+{{ Config.name }}
diff --git a/tests/test_filter_django.py b/tests/test_filter_django.py
index af4f46e..a7ca46a 100644
--- a/tests/test_filter_django.py
+++ b/tests/test_filter_django.py
@@ -26,6 +26,15 @@ class DjangoFilterTests(unittest.TestCase):
os.path.realpath('tests/data/filter/django/title.html.dj'), input)
self.assertEqual(results, "Atom-Powered Robots Run Amok\n")
+ def test_django_config_context(self):
+ config.load('tests/data/filter/django/test.ini')
+ feed = open('tests/data/filter/django/test.xml')
+ input = feed.read(); feed.close()
+ results = dj.run(
+ os.path.realpath('tests/data/filter/django/config.html.dj'), input)
+ self.assertEqual(results, "Django on Venus\n")
+
+
try:
from django.conf import settings
except ImportError:
From 7ba2a1db32ba0f22a375e8b7bfba6f2edc168031 Mon Sep 17 00:00:00 2001
From: Sam Ruby
Date: Thu, 1 Mar 2007 16:00:30 -0500
Subject: [PATCH 5/5] Initialize _no_sed to false
---
tests/test_filters.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_filters.py b/tests/test_filters.py
index 58177fc..02c5f57 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -111,6 +111,7 @@ class FilterTests(unittest.TestCase):
try:
from subprocess import Popen, PIPE
+ _no_sed = False
try:
sed = Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
sed.communicate()