[Zope] calling product ZClass add method

Kevin Dangoor kid@kendermedia.com
Mon, 23 Aug 1999 15:57:20 -0400


-----Original Message-----
From: Chris Walter <walter@budoe.bu.edu>
To: Kevin Dangoor <kid@kendermedia.com>
Cc: zope@zope.org <zope@zope.org>
Date: Monday, August 23, 1999 3:25 PM
Subject: Re: [Zope] calling product ZClass add method


>That's what I get for not blindly following instructions!  I thought
>since in my first little test case I was only adding one instance it
>was harmless to re-direct the output.  It looks like I was wrong.  I
>went ahead and modified multiRes_add and it worked great.  Now I can
>loop through a tinytable and produce multiRes objects just like I
>wanted to.

Cool.

>BTW as far as I am concerned you are a genius for figuring out the
>line:
>
><dtml-with "manage_addProduct['YourProduct']">
>
>by looking at the HTML source.  I don't really know python yet.  What
>is the meaning of the "[]" as opposed to the "()"?  Array instead of
>function?

Essentially, yes. Python lets you implement your own functions that figure
out how to deal with [] or () for a given class. For manage_addProduct, they
essentially made it a dictionary of Products. I admit that I did have to
*guess* that /manage_addProduct/YourProduct/ZClass_factory from the HTML
source maps to manage_addProduct['YourProduct'].ZClass_factory, instead of
manage_addProduct.YourProduct.ZClass_factory. Though, when I think about it
now, it makes a bit of sense because YourProduct is not actually part of
manage_addProduct. manage_addProduct simply "points" to the product.

>In the HOWTO it might be nice to point out that _ is a special
>variable that contains the namespace and people should look in the
>DTML users's guide for more info.

Good idea.

>I thought about this but decided against it.  multiRes is a ZClass for
>displaying multiple resolutions of images stored on a disk.  It can
>display a small image as a link to a larger image.  I thought it was
>useful enough outside of photoCD directories that I might make it
>available to others sometime who might have other uses for it.

This makes sense.

Kevin