Images in Oracle's BLOB Field
Hello, I have stored images in a Oracle's BLOB field. I have tried to display them from Zope in a dtml-in method, but I can not show them. Anybody knows to how do it ? Thanks.- Note: I am using Zope 2.4.1, Python 2.1 and Oracle 8i (with the DCOracle2 Adapter).
Juan Javier Carrera Obrero wrote:
Hello,
Hi,
I have stored images in a Oracle's BLOB field. I have tried to display them from Zope in a dtml-in method, but I can not show them.
Anybody knows to how do it ?
First of all, you must understand that html doesn't include it's displayed images inline in the source document it just puts a reference ('<img src="some url">') telling your browser where it should fetch the image. Hence when you say <dtml-var some_image_object> it is actually asking some_image_object to output an <img src="..."> tag. This <img> tag would be useless if the 'src="..."' part didn't refer to a place that actually served the image. Your <dtml-in> of BLOB fields is most likelly spewing a bunch of data in the html source of your document which your browser is rightfully not showing you as an image. The solution to your problem is twofold: * find a way to query your database and return a list of <img src="..."> tags. * find a way to serve ONE image from the same URL you mentioned in the <img src="..."> above. There are many aproaches to that, almost all involving the creation of Zope products, though maybe you can make do with a method to query the database and another method or script that gets an ID as a parameter and spews one image in return. Don't forget to set your 'Content-Type:' header in this method or script. Cheers, Leo
Juan Javier Carrera Obrero wrote:
Hello,
I have stored images in a Oracle's BLOB field. I have tried to display them from Zope in a dtml-in method, but I can not show them.
Anybody knows to how do it ?
Thanks.-
Note: I am using Zope 2.4.1, Python 2.1 and Oracle 8i (with the DCOracle2 Adapter).
Hi Juan, Sorry I haven't read the list in a while! It seems to me that the way you do this is by explicitly using the LOB.read() mechanism... ie <dtml-with "mySQLqueryWhichReturnsALOB" mapping> <dtml-var expr="LOB.read()"> </dtml-with> Except that you have to be tricky and make sure there are no newlines and so on, so you end up doing like the following (untested, but close): <dtml-call expr="RESPONSE.set_header('content-type','image/jpeg')
<dtml-with ... <next tag <you see the pattern?>
Hi all, The collector seems to still be offline? I just realized that the unrestrictedTraverse returns self for the empty-string url: '' I did expect it to return the root object because the empty-string is equal to the path tuple ('',). Is there any reason for the current behaviour? Does anybody know any bad things that might happen if I change this behaviour? Best Regards, Johan Carlsson
Johan Carlsson [Torped] wrote:
Hi all, The collector seems to still be offline?
I just realized that the unrestrictedTraverse returns self for the empty-string url: '' I did expect it to return the root object because the empty-string is equal to the path tuple ('',).
You convert from a path tuple to a path like this: path='/'.join(path_tuple) While you're correct that the path tuple ('',) is equivalent to the path '', I thing the path '' means "current object". So, the root would be represented by the path '/', and therefore the tuple ('',''). I guess I should go and read the traversal code again... -- Steve Alexander Software Engineer Cat-Box limited
participants (5)
-
Johan Carlsson [Torped] -
Juan Javier Carrera Obrero -
Leonardo Rochael Almeida -
Matthew T. Kromer -
Steve Alexander