[Zope] Viewing a Blob using DTML

Matthew T. Kromer matt@zope.com
Thu, 21 Nov 2002 11:28:10 -0500


working4aliving wrote:

>Hi, I've been working on this for a little, and am stuck... I'm a newbie
>with zope.
>I have a python script that calls a zsql method (mysql), and DOES display
>the image correctly.
>
>(calling the zsql method does not, by the way, it only displays "machine
>code" (old joke.hahaha;) , but that's ok, I think)
>
>When I type the url directly into the browser, and insert my id variable for
>the record, it'll work from the browser, but I can't get it to work through
>dtml.  It will only display the "machine code".
>
>Is there a way to just call the url from dtml while inserting the ID
>variable at  the end? I'm pretty stuck on this, and could really use an
>expert
>
>Here's the python url that works...
>
>http://localhost:8080/blobTest/selectImage1?id=12686
>
>Is this the easiest way to do it?  I've found some various documentation on
>the web, and although helpful, just doesn't get me there....
>
>  
>

Most likely you need to set the proper content-type header, and make 
sure no "extra" stuff goes out on the page besides the image.

For example:

<dtml-call RESPONSE.setHeader('content-type', 'image/jpeg')
 ><!-- Note clever use of line wrap inside tag!
--><dtml-var "selectImage(id=12686)">

-- 
Matt Kromer
Zope Corporation  http://www.zope.com/