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/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 c61f11b..a7ca46a 100644 --- a/tests/test_filter_django.py +++ b/tests/test_filter_django.py @@ -26,9 +26,18 @@ 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: logger.warn("Django is not available => can't test django filters") - del DjangoFilterTests.test_django_filter - del DjangoFilterTests.test_django_item_title + for method in dir(DjangoFilterTests): + if method.startswith('test_'): delattr(DjangoFilterTests,method) diff --git a/tests/test_filters.py b/tests/test_filters.py index fc61e47..02c5f57 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -111,11 +111,18 @@ class FilterTests(unittest.TestCase): try: from subprocess import Popen, PIPE - sed=Popen(['sed','--version'],stdout=PIPE,stderr=PIPE) - sed.communicate() - if sed.returncode != 0: + _no_sed = False + 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