Skip to content

Commit 41af428

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 6836d63 commit 41af428

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Fixed:
2626
- always honor indexme property on Strings (sf patch 1063711)
2727
- make hyperdb value parsing errors readable in mailgw errors
2828
- make anydbm journal export handle removed properties
29+
- allow use of XML templates again
2930

3031

3132
2004-10-15 0.7.8

roundup/cgi/templating.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ def __str__(self):
4848
return 'You are not allowed to %s items of class %s'%(self.action,
4949
self.klass)
5050

51-
def find_template(dir, name, extension):
51+
def find_template(dir, name, view):
5252
''' Find a template in the nominated dir
5353
'''
5454
# find the source
55-
if extension:
56-
filename = '%s.%s'%(name, extension)
55+
if view:
56+
filename = '%s.%s'%(name, view)
5757
else:
5858
filename = name
5959

@@ -63,17 +63,18 @@ def find_template(dir, name, extension):
6363
return (src, filename)
6464

6565
# try with a .html extension (new-style)
66-
filename = filename + '.html'
67-
src = os.path.join(dir, filename)
68-
if os.path.exists(src):
69-
return (src, filename)
70-
71-
# no extension == no generic template is possible
72-
if not extension:
66+
for extension in '.html', '.xml':
67+
filename = filename + extension
68+
src = os.path.join(dir, filename)
69+
if os.path.exists(src):
70+
return (src, filename)
71+
72+
# no view == no generic template is possible
73+
if not view:
7374
raise NoTemplate, 'Template file "%s" doesn\'t exist'%name
7475

7576
# try for a _generic template
76-
generic = '_generic.%s'%extension
77+
generic = '_generic.%s'%view
7778
src = os.path.join(dir, generic)
7879
if os.path.exists(src):
7980
return (src, generic)
@@ -85,7 +86,7 @@ def find_template(dir, name, extension):
8586
return (src, generic)
8687

8788
raise NoTemplate, 'No template file exists for templating "%s" '\
88-
'with template "%s" (neither "%s" nor "%s")'%(name, extension,
89+
'with template "%s" (neither "%s" nor "%s")'%(name, view,
8990
filename, generic)
9091

9192
class Templates:
@@ -98,7 +99,18 @@ def precompileTemplates(self):
9899
''' Go through a directory and precompile all the templates therein
99100
'''
100101
for filename in os.listdir(self.dir):
101-
if os.path.isdir(filename): continue
102+
# skip subdirs
103+
if os.path.isdir(filename):
104+
continue
105+
106+
# skip files without ".html" or ".xml" extension - .css, .js etc.
107+
for extension in '.html', '.xml':
108+
if filename.endswith(extension):
109+
break
110+
else:
111+
continue
112+
113+
# load the template
102114
if '.' in filename:
103115
name, extension = filename.split('.')
104116
self.get(name, extension)

0 commit comments

Comments
 (0)