I have looked at the following example for adding a ZClass in an EXTERNAL METHOD from (http://www.zope.org/Members/tazzzzz/addZClasses): -------------- def addAMyZClass(self, id, REQUEST=None): """ """ # Get the actual destination object, using the this() # method, to be sure we get it in the right context.. self=self.this() # Create the new instance newob=self.Control_Panel.Products.MyProduct.MyZClass(id) newob._setId(id) # Set properties based on the contents of the Add form newob.propertysheets.Basic.manage_changeProperties(REQUEST) # Add a new Folder to the new instance newob.manage_addFolder('foobar') # Add the new instance to the target object self._setObject(id, newob) return 'OK!' ------------------ But, how do you add a nested ZClass. For instance, if MyNestedZClass was a zclass inside of MyZClass? I have tried: ... newob=self.Control_Panel.Products.MyProduct.MyZClass.MyNestedZClass(id) ... But it gives me an attribute error for MyNestedZClass. I have searched and experimented, but I can seem to get a reference to the Nested ZClass. This seems very easy in DTML, but I can't figure it out for external method. Any help is GREATLY appreciated. Thanks, Chris __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/
Chris Bruce writes:
But, how do you add a nested ZClass. For instance, if MyNestedZClass was a zclass inside of MyZClass? I have tried: ... newob=self.Control_Panel.Products.MyProduct.MyZClass.MyNestedZClass(id) ... But it gives me an attribute error for MyNestedZClass. I have searched and experimented, but I can seem to get a reference to the Nested ZClass. This seems very easy in DTML, but I can't figure it out for external method. Do it the same way as in DTML.
There are only two differences between ExternalMethod and DTML: 1. you do not have the magic DTML namespace. This means, you need to know which object provides the name you want to use. 2. You must call methods explicitly and provide the correct parameters. Dieter
But I still don't know which object or method to call? I can call the MyNestedZClass_add method, but it needs the "_" parameter like the following dtml: <dtml-call expr="MyNestedZClass_add(_.none, _, noredir=1)"> but how do I mimick this from an external method, or how can I just create an instance of MyNestedZClass and add it to a folder? If someone can just give me an example of doing it in external method, I am sure the light would turn on and it would all make sense. Thanks Chris --- Dieter Maurer <dieter@handshake.de> wrote:
Chris Bruce writes:
But, how do you add a nested ZClass. For instance, if MyNestedZClass was a zclass inside of MyZClass? I have tried: ...
newob=self.Control_Panel.Products.MyProduct.MyZClass.MyNestedZClass(id)
... But it gives me an attribute error for MyNestedZClass. I have searched and experimented, but I can seem to get a reference to the Nested ZClass. This seems very easy in DTML, but I can't figure it out for external method. Do it the same way as in DTML.
There are only two differences between ExternalMethod and DTML:
1. you do not have the magic DTML namespace. This means, you need to know which object provides the name you want to use.
2. You must call methods explicitly and provide the correct parameters.
Dieter
__________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/
participants (2)
-
Chris Bruce -
Dieter Maurer