summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b4281ca)
raw | patch | inline | side by side (parent: b4281ca)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 6 Sep 2002 22:54:52 +0000 (22:54 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 6 Sep 2002 22:54:52 +0000 (22:54 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1087 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/client.py | patch | blob | history | |
roundup/cgi/templating.py | patch | blob | history |
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index 122c0bc07a936cbfe03d271bd0155e5a94ea4b3d..58a9cffb3036ad473c85d40d15ec1cde79678148 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.19 2002-09-06 07:21:31 richard Exp $
+# $Id: client.py,v 1.20 2002-09-06 22:54:51 richard Exp $
__doc__ = """
WWW request handler (also used in the stand-alone server).
from roundup import roundupdb, date, hyperdb, password
from roundup.i18n import _
-from roundup.cgi.templating import getTemplate, HTMLRequest
+from roundup.cgi.templating import getTemplate, HTMLRequest, NoTemplate
from roundup.cgi import cgitb
from PageTemplates import PageTemplate
except PageTemplate.PTRuntimeError, message:
return '<strong>%s</strong><ol>%s</ol>'%(message,
'<li>'.join(pt._v_errors))
+ except NoTemplate, message:
+ return '<strong>%s</strong>'%message
except:
# everything else
return cgitb.pt_html()
index eea18ce7497ba5d1b0bf2f54fd592d1754ce5bf6..64f871614e8173f090048b6aec8d09c15a6f7cfc 100644 (file)
templates = {}
+class NoTemplate(Exception):
+ pass
+
def getTemplate(dir, name, extension, classname=None, request=None):
''' Interface to get a template, possibly loading a compiled template.
try:
stime = os.stat(src)[os.path.stat.ST_MTIME]
except os.error, error:
- if error.errno != errno.ENOENT or not extension:
+ if error.errno != errno.ENOENT:
raise
+ if not extension:
+ raise NoTemplate, 'Template file "%s" doesn\'t exist'%name
+
# try for a generic template
- filename = '_generic.%s'%extension
- src = os.path.join(dir, filename)
- stime = os.stat(src)[os.path.stat.ST_MTIME]
+ generic = '_generic.%s'%extension
+ src = os.path.join(dir, generic)
+ try:
+ stime = os.stat(src)[os.path.stat.ST_MTIME]
+ except os.error, error:
+ if error.errno != errno.ENOENT:
+ raise
+ # nicer error
+ raise NoTemplate, 'No template file exists for templating '\
+ '"%s" with template "%s" (neither "%s" nor "%s")'%(name,
+ extension, filename, generic)
+ filename = generic
key = (dir, filename)
if templates.has_key(key) and stime < templates[key].mtime: