Skip to content

Commit c230617

Browse files
committed
Self-focument API in templating.py loader class
1 parent 78fc656 commit c230617

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

roundup/cgi/engine_zopetal.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ def __init__(self, dir):
2222
self.dir = dir
2323

2424
def get(self, name, extension=None):
25-
""" Interface to get a template, possibly loading a compiled template.
26-
27-
"name" and "extension" indicate the template we're after, which in
28-
most cases will be "name.extension". If "extension" is None, then
29-
we look for a template just called "name" with no extension.
30-
31-
If the file "name.extension" doesn't exist, we look for
32-
"_generic.extension" as a fallback.
33-
"""
3425
# default the name to "home"
3526
if name is None:
3627
name = 'home'

roundup/cgi/templating.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,25 @@ def precompileTemplates(self):
144144
else:
145145
self.get(filename, None)
146146

147+
def get(self, name, extension=None):
148+
""" Interface to get a template, possibly loading a compiled template.
149+
150+
"name" and "extension" indicate the template we're after, which in
151+
most cases will be "name.extension". If "extension" is None, then
152+
we look for a template just called "name" with no extension.
153+
154+
If the file "name.extension" doesn't exist, we look for
155+
"_generic.extension" as a fallback.
156+
"""
157+
# [ ] document default 'home' template and other special pages
158+
raise NotImplementedError
159+
147160
def __getitem__(self, name):
161+
"""Special method to access templates by loader['name']"""
148162
name, extension = os.path.splitext(name)
149163
if extension:
150164
extension = extension[1:]
151165
try:
152-
# [ ] dispell - add get() definition to this base class
153166
return self.get(name, extension)
154167
except NoTemplate, message:
155168
raise KeyError, message

0 commit comments

Comments
 (0)