[Zope] blob image from MySql

Adriano adriano at euma.com
Tue Mar 1 15:40:28 EST 2005


Andy,

thanks so much for your help, I would have  never 
looked for the db.py module in ZMySQLDA. Really !

Still...


>On Tue, 1 Mar 2005 02:42:26 +0100, Adriano <adriano at euma.com> wrote:
>  > Phillip,

...

>  > "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)
>
>I think I now know the answer.
>
>ZMySQLDA uses the converter dictionary from MySQLdb, though it mostly
>bypasses MySQLdb. Since 1.0.0, MySQLdb returns BLOB columns as
>array(c,...), and previously it returned strings, so now it runs afoul
>of Zope, which expects a string.
>
>There is a section ZMySQLDA/db.py in the DB class that looks like this:
>
>     conv=conversions.copy()
>     conv[FIELD_TYPE.LONG] = int_or_long
>     conv[FIELD_TYPE.DATETIME] = DateTime_or_None
>     conv[FIELD_TYPE.DATE] = DateTime_or_None
>     conv[FIELD_TYPE.DECIMAL] = float
>     del conv[FIELD_TYPE.TIME]
>
>You should add a line after this:
>
>     del conv[FIELD_TYPE.BLOB]
>
>This will cause it to return BLOBs as strings.
>
>I'll have to fix this in ZMySQLDA.

I found the db.py file and updated it adding the

del conv[FIELD_TYPE.BLOB]

row, as you suggested. I restarted Zope in order 
to let it load the modified product but the 
problem is still there.

Well, there's no longer the "array(c,...) 
starting; But it still doesn't work correctly

To be more specific, the downloaded file now starts like:

??? JFIF  H H  ?? C 

it looks not that bad, does it ? ;)

Well, I don't know.


Thank you, anyhow
Bye
Catonano
-- 
" 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 -



More information about the Zope mailing list