summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 83d091b)
raw | patch | inline | side by side (parent: 83d091b)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 24 Jun 2003 04:52:26 +0000 (04:52 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 24 Jun 2003 04:52:26 +0000 (04:52 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1763 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/cgi/templating.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 4a2fa65b6baff0e99de862e95caf9d91676671fd..8724ab03a6c9cc79b908c4f79690a448c02d9304 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- fix :required ordering problem (sf bug 740214)
- audit some user properties for valid values (roles, address) (sf bugs
742968 and 739653)
+- fix HTML file detection (hence history xref linking) (sf bug 741478)
2003-06-10 0.6.0b3
index db1d8ae619c7c063093192f7cfa677df68a98c66..f4707ad061a2d2012b18d5e806438bbf5251885d 100644 (file)
class NoTemplate(Exception):
pass
+def find_template(dir, name, extension):
+ ''' Find a template in the nominated dir
+ '''
+ # find the source
+ if extension:
+ filename = '%s.%s'%(name, extension)
+ else:
+ filename = name
+
+ # try old-style
+ src = os.path.join(dir, filename)
+ if os.path.exists(src):
+ 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)
+
+ # no extension == no generic template is possible
+ if not extension:
+ raise NoTemplate, 'Template file "%s" doesn\'t exist'%name
+
+ # try for a _generic template
+ generic = '_generic.%s'%extension
+ src = os.path.join(dir, generic)
+ if os.path.exists(src):
+ return (src, generic)
+
+ # finally, try _generic.html
+ generic = filename + '.html'
+ src = os.path.join(dir, generic)
+ if os.path.exists(src):
+ return (src, generic)
+
+ raise NoTemplate, 'No template file exists for templating "%s" '\
+ 'with template "%s" (neither "%s" nor "%s")'%(name, extension,
+ filename, generic)
+
class Templates:
templates = {}
# split name
name, extension = name.split('.')
- # find the source, figure the time it was last modified
- if extension:
- filename = '%s.%s'%(name, extension)
- else:
- filename = name
-
- src = os.path.join(self.dir, filename)
- if not os.path.exists(src):
- filename = filename + '.html'
- src = os.path.join(self.dir, filename)
- if not os.path.exists(src):
- if not extension:
- raise NoTemplate, 'Template file "%s" doesn\'t exist'%name
-
- # try for a generic template
- generic = '_generic.%s'%extension
- src = os.path.join(self.dir, generic)
- if not os.path.exists(src):
- generic = '_generic.%s.html'%extension
- src = os.path.join(self.dir, generic)
- if not os.path.exists(src):
- raise NoTemplate, 'No template file exists for '\
- 'templating "%s" with template "%s" (neither '\
- '"%s" nor "%s")'%(name, extension, filename,
- generic)
- filename = generic
+ # find the source
+ src, filename = find_template(self.dir, name, extension)
+ # has it changed?
try:
stime = os.stat(src)[os.path.stat.ST_MTIME]
except os.error, error:
if (self._props.has_key(prop_n) and
isinstance(self._props[prop_n], hyperdb.Link)):
classname = self._props[prop_n].classname
- if os.path.exists(os.path.join(self._db.config.TEMPLATES, classname + '.item')):
- current[prop_n] = '<a href="%s%s">%s</a>'%(classname,
- self._klass.get(self._nodeid, prop_n, None), current[prop_n])
+ try:
+ find_template(self._db.config.TEMPLATES,
+ classname, 'item')
+ except NoTemplate:
+ pass
+ else:
+ id = self._klass.get(self._nodeid, prop_n, None)
+ current[prop_n] = '<a href="%s%s">%s</a>'%(
+ classname, id, current[prop_n])
for id, evt_date, user, action, args in history:
date_s = str(evt_date.local(timezone)).replace("."," ")