|
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 $ |
2 | 2 |
|
3 | 3 | __doc__ = """ |
4 | 4 | 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+)')): |
468 | 468 | if not m: |
469 | 469 | raise NotFound, str(designator) |
470 | 470 | classname, nodeid = m.group(1), m.group(2) |
471 | | - if classname != 'file': |
472 | | - raise NotFound, designator |
473 | 471 |
|
474 | 472 | 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 |
476 | 481 |
|
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() |
480 | 485 |
|
481 | 486 | self._serve_file(lmt, mime_type, content) |
482 | 487 |
|
@@ -543,7 +548,9 @@ def renderContext(self): |
543 | 548 | } |
544 | 549 | try: |
545 | 550 | # 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 |
547 | 554 | except NoTemplate, message: |
548 | 555 | return '<strong>%s</strong>'%message |
549 | 556 | except: |
|
0 commit comments