Skip to content

Commit 2f6b05e

Browse files
author
Richard Jones
committed
commit old file-serving bugfix, and new pt content-type fix
1 parent 43a201a commit 2f6b05e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

roundup/cgi/client.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.149 2003-12-05 03:28:38 richard Exp $
1+
# $Id: client.py,v 1.150 2004-01-15 00:01:15 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -468,15 +468,20 @@ def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')):
468468
if not m:
469469
raise NotFound, str(designator)
470470
classname, nodeid = m.group(1), m.group(2)
471-
if classname != 'file':
472-
raise NotFound, designator
473471

474472
self.opendb('admin')
475-
file = self.db.file
473+
klass = self.db.getclass(classname)
474+
475+
# make sure we have the appropriate properties
476+
props = klass.getprops()
477+
if not pops.has_key('type'):
478+
raise NotFound, designator
479+
if not pops.has_key('content'):
480+
raise NotFound, designator
476481

477-
mime_type = file.get(nodeid, 'type')
478-
content = file.get(nodeid, 'content')
479-
lmt = file.get(nodeid, 'activity').timestamp()
482+
mime_type = klass.get(nodeid, 'type')
483+
content = klass.get(nodeid, 'content')
484+
lmt = klass.get(nodeid, 'activity').timestamp()
480485

481486
self._serve_file(lmt, mime_type, content)
482487

@@ -543,7 +548,9 @@ def renderContext(self):
543548
}
544549
try:
545550
# let the template render figure stuff out
546-
return pt.render(self, None, None, **args)
551+
result = pt.render(self, None, None, **args)
552+
self.additional_headers['Content-Type'] = pt.content_type
553+
return result
547554
except NoTemplate, message:
548555
return '<strong>%s</strong>'%message
549556
except:

0 commit comments

Comments
 (0)