Phillip, Thanks for your kindness, you got a point. I checked and the first row of the file "downloaded" starts with "array('c', ... and then all the strange chars Also, I tried to put an external method like this: ##bind container=container ##bind context=context ##bind namespace= def makeImage(self, photo): return photo[0].iconblob.tostring() (notice the ".tostring()" in the end) and call this external method from my python script In this case the downloaded file does not start like that but still results not recognizable. I tried to open it with Safari abd it shows a empty withe screen Well, at least the tostring() changed the output but still I can't see the pic. I saw a page suggesting to use an external methos like that and I wonder why the http://www.zope.org/Members/murphy/MySQL-BLOBs page doesn't suggest this too. The fact is - I don'y understand the difference in the output. Thanks, anyhow Catonano
On Tue, 1 Mar 2005 01:04:53 +0100, Adriano <adriano@euma.com> wrote:
Dear Zope friends,
I can't manage my Zope to correctly serve an image retrieved from a MySql table.
If the thing has been discussed already, I'm sorry, but I couldn't find so much help, on line.
I followed indications at http://www.zope.org/Members/murphy/MySQL-BLOBs
I have the following ZSQLMethod, named "trovaImmagine" (in Italian that means findImage)
select iconmimetype, iconblob from webs where <dtml-sqltest id op="eq" type="int">
Then, I have a Python script (displayImage2)
# Return a string identifying this script. record = context.trovaImmagine(id = 1) data = record[0].iconblob contentType = record[0].iconmimetype
RESPONSE.setHeader('content-type', contentType) return data #return len(data) #return contentType
The commented returns are some tests I made. When I comment the "return data" part and uncomment the "return contentType" OR "return len(data)", it seems to work correctly
BUT
when I try to return "data" I obtain a message error from FireFox, saying:
"The image "http://localhost:8080/sql/displayImage2" cannot be displayed, because it contains errors."
I tyied with Safari and it downloads a "displayImage2" file , I rename it to displayImage2.jpg, I try to open it with the Apple viewer (Anteprima in Italian, I don't remember in English) AND it says me that the file is not a jpeg file as it seems.
Internet Explorer shows a broken QuickTime icon.
What's going on ?
I'm trying to convince a company to port their little app made of JSPs to Zope and I am doing some tests. They have the pictures in some blob fields so this is unavoidable, I think
It sounds like it's returning some extra data before or after the image. In FireFox you can view source on the page and see the raw image data, it may give you some clues. -- Phillip Hutchings http://www.sitharus.com/ sitharus@gmail.com / sitharus@sitharus.com
-- " One of the tricks here is to get away from thinking that programs have to be composed with only a simple text editor " - Alan Kay - "Java and C++ make you think that the new ideas are like the old ones. Java is the most distressing thing to hit computing since MS-DOS". - Alan Kay - "The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas". -Alan Kay -