[mod_python] Mixing content_type not displaying correct info

Jeff van Aswegen jeffmess at gmail.com
Tue Oct 9 07:39:07 EDT 2007


Hey guys

I am trying to display 2 content types under 1 function/webpage,
'image/jpeg' and 'text/html' but this is not working out. I am trying to
display a portion of an image and underneath that image have 3 text fields
that a capturer can enter some information on the image. This is what I have
so far.

def show_image(req):
    width, height = 1000, 1000

    img = Image.open('/home/jeffmess/images/taco/F0476544.JPG')
    img = img.resize((width,height), Image.ANTIALIAS)
    box = (300,335,740,680)
    region = img.crop(box)
    img.paste(region, box)
    s = StringIO()
    region.save(s, 'jpeg')
    file.write(s.getvalue())
    file.close()
    req.content_type = 'image/jpeg'

    req.write(s.getvalue())
    img.close()

    return apache.OK

Now on the same page if I include a random text field say,

    req.content_type = "text/html"
    req.write("""<INPUT TYPE='text' NAME='field0' ID='field0'
ONKEYDOWN='return tabOnEnter (this, event);' >""")

Browsing to the page will show the text field but the image will all be
jargon. Can anyone perhaps offer some advice or point me in the right
direction? Thanks

Regards

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20071009/09bb6e74/attachment.html


More information about the Mod_python mailing list