[Zope] Instance within Instance

Tim Cook twcook@iswt.com
Tue, 28 Nov 2000 22:30:05 -0600


Daryl Stultz wrote:
> 
> Tim Cook wrote:
> 
> > I guarantee that you will end up with a folder MyClass1ID that
> > contains MyClass2ID.
> 
> You've been very helpful, here, Tim, but I simply can't get this to
> work. I'm wondering if you might be able to create such a product for me
> and send it to me: One product with two classes, creating one class from
> the manager creates the first class with the second inside it.

I probably didn't give all of the instructions in a step by step
manner. I think I gathered this info from different HOWTOs. Here
are the changes that I make to each ZClass.

In the class definition add your propertysheet(s). I only ever
use one / class. I think this is a hold over from years of
RDBMS's. I figure if you need more than one propertysheet then
you need a seperate class. <s>

In the constructor, copy the call to manage_editProperties to a
new one outside of the comment block. Replace the .Basic. with
the name of your property sheet you created.

So:
...
     <dtml-call
"propertysheets.Basic.manage_editProperties(REQUEST)">

  </dtml-comment>
</dtml-with>

Becomes:
...

       <dtml-call
"propertysheets.Basic.manage_editProperties(REQUEST)">

  </dtml-comment>
  <dtml-call
"propertysheets.myclass1_info.manage_editProperties(REQUEST)">

</dtml-with>


Then at the bottom of the constructor (I think I got this from
the Job Board HowTo).

Replace everything below the </dtml-comment> with:

<dtml-if NoRedir>
<dtml-else>

<dtml-if DestinationURL>

 <dtml-call "RESPONSE.redirect(
       DestinationURL+'/manage_workspace')">

<dtml-else>

    <dtml-call "RESPONSE.redirect(
           URL2+'/manage_workspace')">
</dtml-if>
</dtml-if>
</body></html>

When we call the constructor we will pass 'NoRedir', this keeps
it from returning to the management interface. 

After setting up REQUEST with our desired values for the
propertysheet we call the first constructor like this:

<dtml-call expr="REQUEST.set('id', 'MyClass1ID')">

<dtml-with "manage_addProduct['MyCoolProduct']">
  <dtml-call expr="MyClass1_add(_.None, _, NoRedir=1)">
</dtml-with>

Next we get the newly constructed MyClass1, and setup to call the
MyClass2 constructor:

<dtml-with "_.getitem('id')">

  <dtml-call expr="REQUEST.set('id', 'MyClass2ID')">

  <dtml-with "manage_addProduct['MyCoolProduct']">
    <dtml-call expr="MyClass2_add(_.None, _, NoRedir=1)">
  </dtml-with>

</dtml-with>

-------------------------------
I am sending you a Product and an example folder via seperate
email.

> Maybe I can write some Python for you or something in exchange :-)

Just signup on the FreePM project at SourceForge & mailing list
and I'll be sure to ask real soon now. <g>

Good Luck,
-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.