[Zope] Adding a ZClass Instance to a Specific Folder

Tim Cook twcook@iswt.com
Thu, 21 Dec 2000 19:45:29 -0600


"Leichtman, David J" wrote:
> 


> And when you programmatically add a ZClass instance, it's like this:
> <dtml-with "manage_addProducts('Your_product')">
>   <dtml-call "ZClass_name.ZClass_name_add(_.None,_)">
> </dtml-with>
> This creates the instance in the directory of the method from which the
> call was made.
> 
> The Question:
> How do you go about adding an instance to a specific folder? I can't,
> for the life of me, figure it out. I've tried many different things,
> and I've looked for flags in createObjectInFolder, but to no avail.

You can wrap the call in another dtml-with.

<dtml-with my_desired_folder>
 <dtml-with "manage_addProducts('Your_product')">
   <dtml-call "ZClass_name.ZClass_name_add(_.None,_)">
 </dtml-with>
</dtml-with>

That is assuming that my_desired_folder is aquirable(?) You may
need multiple -with's. Also using dotted syntax may work so that
you can use a single -with, i.e. <dtml-with
outer_folder.my_desired_folder>. I haven't tried this and I'm
sure one of the gurus here will let us know if this would work.

The other situation I ran into was when creating multiple nested
folders was that I only had the id of my_desired_folder as a
string so I had to use <dtml-with "_.getitem(id)">.

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