Re: [Zope] calling product ZClass add method
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 )
On Mon, 23 Aug 1999, Kevin Dangoor wrote:
Hi, Chris
You've given me a good impetus to figure this out once and for all :)
Hi Kevin, Thanks, this is definitely closer. In the product directory photoCD I have ZClasses multiRes and photoCD. I'm in an instance of a photoCD class(which inherits from Folder) somewhere in my site and I am trying to add an instance of a multiRes. So I added this to my method in photoCD. <dtml-with "manage_addProduct['photoCD']"> <dtml-call "multiRes_add(_.None, _, NoRedir=1)"> </dtml-with> since I want something in the photoCD product directory and what I want is a multiRes ZClass right? So If I do this I get the following odd error message: Error Type: AttributeError Error Value: _u Here is part of the traceback: ... File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: manage_addProduct['photoCD']) File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 315, in eval (Object: multiRes_add(_.None, _)) File <string>, line 0, in ? File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/OFS/DTMLMethod.py, line 141, in __call__ (Object: multiRes_add) File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: multiRes_add) File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/App/FactoryDispatcher.py, line 126, in DestinationURL AttributeError: (see above) If I call multiRes_add with no paramaters then it calls it properly but the name space is wrong. Any thoughts? Thanks a lot for your help I really apreciate it. -Chris
participants (2)
-
Chris Walter -
Kevin Dangoor