[Zope] Anyone put Images in Interbase 6 and view via Zope? (fwd)

Bob Tierney bob.tierney@goingv.com
Thu, 28 Sep 2000 15:16:20 -0400 (EDT)


_________________________________________________________________

Robert E. Tierney                   EMail: bob.tierney@goingv.com
Going Virtual                        HTTP: www.goingv.com
10800 Independence Pointe Pkwy      Phone: 1-704-849-0731 x109
Matthews, NC 28105                    Fax: 1-704-849-2279
                                      AIM: RETierney
_________________________________________________________________

---------- Forwarded message ----------
Date: Thu, 28 Sep 2000 15:15:47 -0400 (EDT)
From: Bob Tierney <btierney@goingv.com>
To: Brad Clements <bkc@murkworks.com>
Subject: Re: [Zope] Anyone put Images in Interbase 6 and view via Zope?


Brad,

I think I can provide some information. I have added a jpg to an interbase
table and have successfuly displayed it in ZOPE.  First off you may know
that Interbase does not store BLOB data directly in a table's blob column.
It stores the data elsewhere and then stores a "pointer" to it in the
table column.  This means that BLOB data MUST be inserted via program code
and thus you cannot do the following in a Zope SQL Method:

insert into the_table (blob_column) values (blob_data)

If you are using the gvibDA you can code an external method to do this:

import gvib
cn = gvib.connect(...)
cr = cn.cursor()
cr.execute('insert into the_table (blob_column values (?)', (blob_data,))
cn.commit()
cr.close()
cn.close()


What I did to display the JPG may or may not be legal but here is what I
did.


Code an external method (saveimage) to save the jpg to a temporary file.
My codewas:

    def saveimage(ifile, idata):
        fout = open(ifile, 'wb')
        fout.write(idata)
        fout.close()



Then I coded an SQL Method to select the blob column. My example table has
one row in it.

    select picture from sela  

Then I coded a DTML Method to do the rest:

    <dtml-in selasql>
        <dtml-call "saveimage('/tmp/sela.jpg', picture)">
        <img src="file:/tmp/sela.jpg" alt='sela'>
    </dtml/in

When 'viewed' the reulst is a nice picture of the lovely Sela Ward.  :-)


Good Luck and Regards,

Bob Tierney

_________________________________________________________________

Robert E. Tierney                   EMail: bob.tierney@goingv.com
Going Virtual                        HTTP: www.goingv.com
10800 Independence Pointe Pkwy      Phone: 1-704-849-0731 x109
Matthews, NC 28105                    Fax: 1-704-849-2279
                                      AIM: RETierney
_________________________________________________________________

On Thu, 28 Sep 2000, Brad Clements wrote:

> Just wondering if anyone can report success or failure storing .jpgs as 
> blobs in Interbase and viewing same via Zope.
> 
> Thanks
> 
> 
> Brad Clements,                bkc@murkworks.com   (315)268-1000
> http://www.murkworks.com                          (315)268-9812 Fax
> netmeeting: ils://ils.murkworks.com               AOL-IM: BKClements
> 
> _______________________________________________
> 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 )
> 
>