[Zope] 1 - Images on fly from DB

Matt Hamilton matth at netsight.co.uk
Mon Apr 19 05:30:07 EDT 2004


> Hi !
>
> My problem is that:
> I have an image "library" in FireBird database (gdb).
>
> I want to show the images in zope site, but I don't know, how to
transform from blob field to real image (in html page).
>
> I want to use this conversion time-to-time, not at once, because it is
database specific "data".
>
> Can anyone help me ?

You will need to construct an Image (or File) object instance dynamically
from your data.


The following (untested) python code may be a starting point. As it has to
wrap an object i think it will have to be an external method:

def getImage(self):
  from OFS.Image import Image
  data = self.my_sql_call_to_get_data()

  im = Image('id_of_image', 'title_of_image', data)
  # wrap the object so it has a context wrapper
  im = im.__of__(self)
  return im


Hope this helps.

-Matt

-- 
Matt Hamilton                                         matth at netsight.co.uk
Netsight Internet Solutions, Ltd.          Business Vision on the Internet
http://www.netsight.co.uk                               +44 (0)117 9090901
Web Design | Zope/Plone Development and Consulting | Co-location | Hosting







More information about the Zope mailing list