[Zope] calling product ZClass add method

Kevin Dangoor kid@kendermedia.com
Mon, 23 Aug 1999 13:48:37 -0400


Hi, Chris

    You've given me a good impetus to figure this out once and for all :)

    I've updated the HOWTO a bit more... It's now pretty complete with
regards to adding ZClass instances from DTML. Here's a new paragraph that is
relevant to what you're trying to do:

  If you are trying to add a ZClass instance from elsewhere in
the ZODB, it's just a couple of lines more that are necessary::

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


    How did I come up with this, you ask? I pulled out a crystal ball and
attempted to channel the brains of the DCers up here. Since they were
resistant to that particular crystal ball, I resorted to using the "View
Source" command in the browser. Basically, when you add a ZClass instance
from the management interface, it calls
current_url/manage_addProduct/YourProduct/YourZClass_factory. The factory
serves up the addForm method, which then posts to the add method. Through
all of this, you're working a couple levels below the destination URL, and
the addProduct machinery is designed to handle this so that the new object
ends up in the right place.

    The (_.None, _) parameters are there to pass in the namespace. I believe
that this is necessary since the YourZClass_add method exists in the Control
Panel. You don't need this when calling most ZClasses, because they are in
more "normal" parts of the ZODB and have access to the things you would want
them to...

Kevin

-----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 12:12 PM
Subject: Re: [Zope] calling product ZClass add method


>
>
>On Mon, 23 Aug 1999, Kevin Dangoor wrote:
>
>>     I'm working on a HOWTO for this. It should be done later today... The
>> first bit is there now, but I need to do some more testing/playing
around...
>>
>>     http://www.zope.org:18200/Members/tazzzzz/addZClasses
>>
>> Kevin
>
>Hi Kevin,
>
>Thanks for the response. Your howto is clear(although I don't
>understand the _.None,_).
>
>Unfortunately it's not really what I need.  I am trying to add a ZClass
>instance inside of *another type* of ZClass instance.  So the ZClass
>instance is not a method of the ZClass itself.
>
>The closest I have come is something like this:
>
><dtml-call "Control_Panel.Products.photoCD.multiRes_add(pcd0686,REQUEST)">
>
>Unfortunately then the name space isn't right and the multiRes_add
>method can't find multiRes.  I tried encasing the whole thing in
>various dtml-withs like this:
>
><dtml-with Control_Panel>
><dtml-with Products>
><dtml-with photoCD>
><dtml-call "Control_Panel.Products.photoCD.multiRes_add(pcd0686,REQUEST)">
></dtml-with>
></dtml-with>
></dtml-with>
>
>and this almost works except that then it produces the instance in the
>Products/photoCD directory instead of where I am calling it from.
>
>-Chris
>walter@budoe.bu.edu
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://www.zope.org/mailman/listinfo/zope
>
>(To receive general Zope announcements, see:
>http://www.zope.org/mailman/listinfo/zope-announce
>
>For developer-specific issues, zope-dev@zope.org -
>http://www.zope.org/mailman/listinfo/zope-dev )
>