Zope mailing lists wrote:

> I have a specialist (actually, EMarket has a specialist <grin>) that
> manages objects that from a design point of view I think should have
> a couple of Images as attributes (thumbnail and fullsized images of
> the product).  The question is, how do I implement this using
> ZPatterns?  Currently all of the other object data is pulled from an SQL
> database.  I don't mind storing the Images in the ZODB, but I'm having
> a hard time finguring out how I would implement that.  Pointers or
> alternate design suggestions welcome.

Here's the simplest approach that I can think of.

Stick all your images in a BTree Folder somewhere convenientm like 
/Images. Name all the images "image-NNNNNN" where NNNNNN is a unique number.

Make a couple of columns in your database (or whatever) for thumbnail_id 
and large_image_id. You'll store the image ids in these.

Use some SkinScript in that Specialist you mentioned that gets the 
thumbnail_id and large_image_id for a particular object, and also makes 
available the thumbnail and large_image.

WITH QUERY get_thumbnail_for_object_SQL(primary_key=self.id) COMPUTE

Note here that I could have had just "thumbnail_id," at line 2.
Also, note that I'm assuming you have an image called missing_thumbnail 
in the Images folder.

Do likewise for large images.

This approach assumes that you're not considering images or thumbnails 
to be first-class domain objects in your system, but just attributes of 
your main objects. Thus, you won't be wanting to store other data that 
is pertinent to images. If you do want to do this, you should use a more 
complex design where Images have their own specialist.

Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to