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.... Thanks in advance. This group (and the product) are great. Bob
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.
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".
Hi, you have to set the correct HTTP-Header when you want to server your image from a DTML-Method. something like this should do it: ~~~ Content-type: image/gif <dtml-var yourImageScriptWhichGivesYouTheMachineCode> ~~~ -mj -- German Zope User Group http://www.dzug.org/
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/
Thanx Matt and Maik... You both steered me, and it works... (needless to say, I'm pretty damn happy right now :))) ) Seems like I didn't need the RESPONSE.setheader (yet???) Here's the method (requestImage1) <form action="selectImage1"> <input type="text" name="Id"><br> <input type="submit"> </form> Here's the python script(selectImage1) #image1 is the name of the field result = [] lob = ['image1'] for row in context.sql_db_image1(id=id): lob = row['image1'] return lob ----- Original Message ----- From: "Matthew T. Kromer" <matt@zope.com> To: "working4aliving" <working4aliving@hotmail.com> Cc: <zope@zope.org> Sent: Thursday, November 21, 2002 11:28 AM Subject: Re: [Zope] Viewing a Blob using DTML
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/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi working, whats the reason in not using a python script? You said early you had it working with python script. So why hassle with the ugly DTML? Regards Tino --On Donnerstag, 21. November 2002 12:12 -0500 working4aliving <working4aliving@hotmail.com> wrote:
Thanx Matt and Maik... You both steered me, and it works... (needless to say, I'm pretty damn happy right now :))) ) Seems like I didn't need the RESPONSE.setheader (yet???)
Here's the method (requestImage1)
<form action="selectImage1"> <input type="text" name="Id"><br> <input type="submit"> </form>
Here's the python script(selectImage1) # image1 is the name of the field result = [] lob = ['image1'] for row in context.sql_db_image1(id=id): lob = row['image1'] return lob
----- Original Message ----- From: "Matthew T. Kromer" <matt@zope.com> To: "working4aliving" <working4aliving@hotmail.com> Cc: <zope@zope.org> Sent: Thursday, November 21, 2002 11:28 AM Subject: Re: [Zope] Viewing a Blob using DTML
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/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Tino Wildenhain schrieb:
Hi working,
whats the reason in not using a python script? You said early you had it working with python script. So why hassle with the ugly DTML?
I do the following in a Python script called getFoto: foto = context.db.getFoto(Person_ID=pid) container.REQUEST.RESPONSE.setHeader('content-type', 'image/' + foto[0].Type) return foto[0].Pic (where Type is the second part of the MIME type and Pic is the BLOB data) and can call that script simply in a <img> tag: <img src="getFoto?pid=&dtml-PID;" alt="Foto"> Seems to me a more elegant solution. Martin
participants (5)
-
Maik Jablonski -
Martin Gebert -
Matthew T. Kromer -
Tino Wildenhain -
working4aliving