[Zope] ZClass newbie problem...

Kevin Dangoor kid@kendermedia.com
Wed, 14 Jun 2000 11:17:53 -0400


----- Original Message -----
From: "Eric L. Walstad" <Eric@Walstads.net>
To: <zope@zope.org>
Sent: Tuesday, June 13, 2000 12:30 AM
Subject: [Zope] ZClass newbie problem...


> I'm stuck. I would like to build a "shiny new ZClass" that has the
following
> structure:
>
> WebSimProduct
>   WebSim Class
>     'Properties' Property Sheet
>       string RunID
>     Calc Class Object
>       'Properties' Property Sheet
>         PathToInputFile
>         PathToWxFolder
>       Results Class Object
>         'Properties' Property Sheet
>           float gashtg
>           float elchtg
>           float elcclg
>           float euihtg
>           float euiclg
>
> I haven't seen anything in the Zope documentation on using Zclass
instances
> as members of a super class.  In other programming languages I would
> instantiate default objects when the WebSim class is initialized.  That
way,
> to use a WebSim object, all I would need to do is instantiate one, then
fill
> the properties of the automatiacally-created Calc object and Results
object.
> However, I'm not sure how to build these default objects in Zope.
>
> My next question is: do I have to build a bunch of products (one for the
> Calc class and one for the Results class, for example)?  I can imagine
this
> would result in a huge number of products under the control panel if this
is
> the case.  I would like to have just a WebSim product and have all the
other
> classes defined within this product.  Does Zope work this way?  If not,
how
> is this class structure (or one similar) achieved?

You can certainly have multiple ZClasses within a single Product. Some
people recommend not nesting ZClasses, because when you do so you can only
use the nested classes within the top level class... ZClasses can't be
cut-and-pasted, so you're stuck with that hierarchy. If you're sure you only
want to add those classes in that particular way, you can pretty easily do
what you want.

In the WebSim_add method, you would do something like:

<dtml-with "createInObjectManager...">        this line is already there
 <dtml-with "Calc_add(_.None, _)">
  ...set your properties here...
   <dtml-with "Results_add(_.None, _)">
     ...set your Results properties here...
    </dtml-with>
  </dtml-with>
</dtml-with>

HTH,

Kevin