comparison roundup/cgi/client.py @ 1967:d30cd44321f2

commit old file-serving bugfix, and new pt content-type fix
author Richard Jones <richard@users.sourceforge.net>
date Thu, 15 Jan 2004 00:01:15 +0000
parents c538a64b94a7
children b019d0194d27
comparison
equal deleted inserted replaced
1966:c8d8d03b6d94 1967:d30cd44321f2
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 __doc__ = """ 3 __doc__ = """
4 WWW request handler (also used in the stand-alone server). 4 WWW request handler (also used in the stand-alone server).
5 """ 5 """
6 6
466 ''' 466 '''
467 m = dre.match(str(designator)) 467 m = dre.match(str(designator))
468 if not m: 468 if not m:
469 raise NotFound, str(designator) 469 raise NotFound, str(designator)
470 classname, nodeid = m.group(1), m.group(2) 470 classname, nodeid = m.group(1), m.group(2)
471 if classname != 'file': 471
472 self.opendb('admin')
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'):
472 raise NotFound, designator 478 raise NotFound, designator
473 479 if not pops.has_key('content'):
474 self.opendb('admin') 480 raise NotFound, designator
475 file = self.db.file 481
476 482 mime_type = klass.get(nodeid, 'type')
477 mime_type = file.get(nodeid, 'type') 483 content = klass.get(nodeid, 'content')
478 content = file.get(nodeid, 'content') 484 lmt = klass.get(nodeid, 'activity').timestamp()
479 lmt = file.get(nodeid, 'activity').timestamp()
480 485
481 self._serve_file(lmt, mime_type, content) 486 self._serve_file(lmt, mime_type, content)
482 487
483 def serve_static_file(self, file): 488 def serve_static_file(self, file):
484 ''' Serve up the file named from the templates dir 489 ''' Serve up the file named from the templates dir
541 'ok_message': self.ok_message, 546 'ok_message': self.ok_message,
542 'error_message': self.error_message 547 'error_message': self.error_message
543 } 548 }
544 try: 549 try:
545 # let the template render figure stuff out 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 except NoTemplate, message: 554 except NoTemplate, message:
548 return '<strong>%s</strong>'%message 555 return '<strong>%s</strong>'%message
549 except: 556 except:
550 # everything else 557 # everything else
551 return cgitb.pt_html() 558 return cgitb.pt_html()

Roundup Issue Tracker: http://roundup-tracker.org/