Mailing List Archive

Retrieving an image from MySQL
I have an image stored in MSQL.(Don't tell me its not proper do that,I know already).Anyways I need to display it in DTML.

StockChartManagePreview (DTML)

<dtml-var standard_html_header>
<img src="StockChartManagePreview_Handler">
<dtml-var standard_html_footer>

StockChartManagePreview_Handler (python script)

request = container.REQUEST
response = request.RESPONSE
photo = context.StockChartManage_getImage(ID = 6666)
context.REQUEST.RESPONSE.setHeader('content-type','image/jpeg')
return photo[0].image.read()
#I already tried - return photo[0].image
#it gives an error image cannot be displayed because it contains errors


StockChartManage_getImage (Z SQL Method)

SELECT image
FROM `imagebase`
WHERE imageID =<dtml-sqlvar ID type="string">


Now my problem is that Zope asks for a login every time I view the DTML (StockChartManagePreview )

Please Help.

ref : https://mail.zope.org/pipermail/zope-db/2004-July/003336.html
http://www.zope.org/Members/murphy/MySQL-BLOBs
http://www.gossamer-threads.com/lists/zope/db/168437 http://www.zope.org/Members/murphy/MySQL-BLOBs
Re: Retrieving an image from MySQL [ In reply to ]
Hi Jibin,

You are now trying to put an image file (the actual image data) into the
src attribute of your <img> tag. I think the src attribute should
contain the url pointing to your StockChartManagePreview_Handler script.

This is, assuming that your script does correctly return the image file.

Bart

Op 28-06-11 05:56, Jibin K.J schreef:
> I have an image stored in MSQL.(Don't tell me its not proper do that,I
> know already).Anyways I need to display it in DTML.
>
> StockChartManagePreview (DTML)
>
> <dtml-var standard_html_header>
> <img src="StockChartManagePreview_Handler">
> <dtml-var standard_html_footer>
>
> StockChartManagePreview_Handler (python script)
>
> request = container.REQUEST
> response = request.RESPONSE
> photo = context.StockChartManage_getImage(ID = 6666)
> context.REQUEST.RESPONSE.setHeader('content-type','image/jpeg')
> return photo[0].image.read()
> #I already tried - return photo[0].image
> #it gives an error image cannot be displayed because it contains errors
>
>
> StockChartManage_getImage (Z SQL Method)
>
> SELECT image
> FROM `imagebase`
> WHERE imageID =<dtml-sqlvar ID type="string">
>
>
> Now my problem is that Zope asks for a login every time I view the DTML
> (StockChartManagePreview )
>
> Please Help.
>
> ref : https://mail.zope.org/pipermail/zope-db/2004-July/003336.html
> http://www.zope.org/Members/murphy/MySQL-BLOBs
> http://www.gossamer-threads.com/lists/zope/db/168437
>
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> https://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Retrieving an image from MySQL [ In reply to ]
Whoeps, I misread your post. You are doing exactly what I adviced. You
can ignore my previous reply. Sorry.

Bart

PS. thanks Peter for informing me.

Op 28-06-11 13:28, Bart Jansen schreef:
> Hi Jibin,
>
> You are now trying to put an image file (the actual image data) into the
> src attribute of your<img> tag. I think the src attribute should
> contain the url pointing to your StockChartManagePreview_Handler script.
>
> This is, assuming that your script does correctly return the image file.
>
> Bart
>
> Op 28-06-11 05:56, Jibin K.J schreef:
>> I have an image stored in MSQL.(Don't tell me its not proper do that,I
>> know already).Anyways I need to display it in DTML.
>>
>> StockChartManagePreview (DTML)
>>
>> <dtml-var standard_html_header>
>> <img src="StockChartManagePreview_Handler">
>> <dtml-var standard_html_footer>
>>
>> StockChartManagePreview_Handler (python script)
>>
>> request = container.REQUEST
>> response = request.RESPONSE
>> photo = context.StockChartManage_getImage(ID = 6666)
>> context.REQUEST.RESPONSE.setHeader('content-type','image/jpeg')
>> return photo[0].image.read()
>> #I already tried - return photo[0].image
>> #it gives an error image cannot be displayed because it contains errors
>>
>>
>> StockChartManage_getImage (Z SQL Method)
>>
>> SELECT image
>> FROM `imagebase`
>> WHERE imageID =<dtml-sqlvar ID type="string">
>>
>>
>> Now my problem is that Zope asks for a login every time I view the DTML
>> (StockChartManagePreview )
>>
>> Please Help.
>>
>> ref : https://mail.zope.org/pipermail/zope-db/2004-July/003336.html
>> http://www.zope.org/Members/murphy/MySQL-BLOBs
>> http://www.gossamer-threads.com/lists/zope/db/168437
>>
>>
>>
>> _______________________________________________
>> Zope maillist - Zope@zope.org
>> https://mail.zope.org/mailman/listinfo/zope
>> ** No cross posts or HTML encoding! **
>> (Related lists -
>> https://mail.zope.org/mailman/listinfo/zope-announce
>> https://mail.zope.org/mailman/listinfo/zope-dev )
> _______________________________________________
> Zope maillist - Zope@zope.org
> https://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )
>
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )