I just got this to work.... easy, though almost sickeningly easy... :)

>From the CherryPy example add this:

========================
import cherrypy

def mimetype(type):
    def decorate(func):
        def wrapper(*args, **kwargs):
            cherrypy.response.headerMap['Content-Type']=type
            return func(*args, **kwargs)
        return wrapper
    return decorate
=========================

Then I built an 'imgsrv' method.

===========================
@turbogears.expose()
@mimetype('image/jpeg')
def imgsrv(self, img):
    if '''Add validation routines here'''
        img = ('/home/jared/images/%s' % img)
        f = open(img, 'r')
        return f.read()
    else:
        '''Redirect when validation fails'''
===========================

Reply via email to