[Zope] Zope + PostgreSQL + BLOBS, how?

Hannu Krosing hannu@tm.ee
Sun, 09 Jan 2000 15:11:50 +0200


JB wrote:
> Steen Suder wrote:
> > 
> > Is it possible to store, say, staff pictures in PostgreSQL and then show
> > them on a webpage served by Zope?
> > 
> > Like:
> > PostgreSQL -> DA -> Zope -> webpage
> > 
> > If it is possible; can someone give me a few guidelines or hints on how
> > it is done?
> > 
> > I've never worked with BLOBs, but have done lot of standard SQL stuff,
> > also with Zope.
> 
> I realize this isn't the answer to your question, but I have a large
> photo database
> that I am serving out of zope (1500+ images). I keep the photos indexed
> by name on the disk and alias the directory with apache. Then I use an
> external method to hand me back a string of either <IMG
> SRC='/apache_alias/image_key.jpg'> or a 'No image found' string,
> depending on the results of the key search. I went this way because from
> what I understand of postgres, this is much faster than using the large
> object methods. Plus I can mess with the images directly without having
> to use postgres to get at them.

And if one wants to be real creative one could write a PostgreSQL function 
that saves/retrieves the image from file system. 

so
 select saveimage('filename','base64encodedGif')
saves the image and 
 select retrievimage('filename')
gets it back, either as binary or base64 encoded string, depending on 
the cursor mode.

It should be feasible now that PostgreSQL has no limits on Query length.

But of course keeping them in filesüstem seems to make more sense to just 
keep images in file system.

---------------
Hannu