changeset 2960:409510fcb18f maint-0.7

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Thu, 25 Nov 2004 22:26:36 +0000
parents 4129ecd31eea
children d29673626906
files CHANGES.txt roundup/cgi/templating.py
diffstat 2 files changed, 25 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Thu Nov 25 22:14:05 2004 +0000
+++ b/CHANGES.txt	Thu Nov 25 22:26:36 2004 +0000
@@ -26,6 +26,7 @@
 - always honor indexme property on Strings (sf patch 1063711)
 - make hyperdb value parsing errors readable in mailgw errors
 - make anydbm journal export handle removed properties
+- allow use of XML templates again
 
 
 2004-10-15 0.7.8
--- a/roundup/cgi/templating.py	Thu Nov 25 22:14:05 2004 +0000
+++ b/roundup/cgi/templating.py	Thu Nov 25 22:26:36 2004 +0000
@@ -48,12 +48,12 @@
         return 'You are not allowed to %s items of class %s'%(self.action,
             self.klass)
 
-def find_template(dir, name, extension):
+def find_template(dir, name, view):
     ''' Find a template in the nominated dir
     '''
     # find the source
-    if extension:
-        filename = '%s.%s'%(name, extension)
+    if view:
+        filename = '%s.%s'%(name, view)
     else:
         filename = name
 
@@ -63,17 +63,18 @@
         return (src, filename)
 
     # try with a .html extension (new-style)
-    filename = filename + '.html'
-    src = os.path.join(dir, filename)
-    if os.path.exists(src):
-        return (src, filename)
+    for extension in '.html', '.xml':
+        filename = filename + extension
+        src = os.path.join(dir, filename)
+        if os.path.exists(src):
+            return (src, filename)
 
-    # no extension == no generic template is possible
-    if not extension:
+    # no view == no generic template is possible
+    if not view:
         raise NoTemplate, 'Template file "%s" doesn\'t exist'%name
 
     # try for a _generic template
-    generic = '_generic.%s'%extension
+    generic = '_generic.%s'%view
     src = os.path.join(dir, generic)
     if os.path.exists(src):
         return (src, generic)
@@ -85,7 +86,7 @@
         return (src, generic)
 
     raise NoTemplate, 'No template file exists for templating "%s" '\
-        'with template "%s" (neither "%s" nor "%s")'%(name, extension,
+        'with template "%s" (neither "%s" nor "%s")'%(name, view,
         filename, generic)
 
 class Templates:
@@ -98,7 +99,18 @@
         ''' Go through a directory and precompile all the templates therein
         '''
         for filename in os.listdir(self.dir):
-            if os.path.isdir(filename): continue
+            # skip subdirs
+            if os.path.isdir(filename):
+                continue
+
+            # skip files without ".html" or ".xml" extension - .css, .js etc.
+            for extension in '.html', '.xml':
+                if filename.endswith(extension):
+                    break
+            else:
+                continue
+
+            # load the template
             if '.' in filename:
                 name, extension = filename.split('.')
                 self.get(name, extension)

Roundup Issue Tracker: http://roundup-tracker.org/