I've a class with a property myparent This property needs to be set after a new instance is added or when the instance is moved. Thanks to people from the list, I know I've to make an external method and add the external method manage_afterAdd to the methods of the class. This is how the method looks: def manage_afterAdd(self,item,container): item.myparent=container.id return Unfortunately, when I add a new instance and then look at the myparent property, the property is empty, while it should have a value. What am I doing wrong? tom.
----- Original Message ----- From: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be> To: <zope@zope.org> Sent: Monday, February 28, 2000 12:00 PM Subject: [Zope] Again: manage_afterAdd
I've a class with a property myparent This property needs to be set after a new instance is added or when the instance is moved.
Thanks to people from the list, I know I've to make an external method and add the external method manage_afterAdd to the methods of the class.
This is how the method looks:
def manage_afterAdd(self,item,container): item.myparent=container.id return
This is a ZClass, right? It should be: item.propertysheets.YourPropsheet.manage_changeProperties({'myparent' : container.id}) Kevin
I've a class with a property myparent This property needs to be set after a new instance is added or when the instance is moved.
Thanks to people from the list, I know I've to make an external method and add the external method manage_afterAdd to the methods of the class.
This is how the method looks:
def manage_afterAdd(self,item,container): item.myparent=container.id return
This is a ZClass, right?
It should be:
item.propertysheets.YourPropsheet.manage_changeProperties({'myparent' : container.id})
Kevin
Yes, it's a ZClass with in it's method's tab an external method called : 'manage_afterAdd' The external method itself is python code (see source above) The intention of this method is that it sets the 'myparent' property to a value (dependend on its parent) when an instance of the ZClass is created or when the instance is moved. The problem is that nothing happens! 'myparent' property keeps empty. I also don't get an error value... :-( urgh, really frustrating... I don't know what I'm doing wrong and I don't know where to look for the problem :-((( Tom.
Hi Tom, I have not followed the thread so might be talking nonsense ... but today I am in the mood for talking nonsense anyway ... On Mon, 28 Feb 2000, Tom Deprez wrote:
I've a class with a property myparent This property needs to be set after a new instance is added or when the instance is moved.
The way I would do it is in your products add method, say if your ZClass is named SuperDeprezClass then the method should be SuperDeprezClass_add. in there you can add: <dtml-call "propertysheets.<propertysheet name>.manage_editProperties( REQUEST)"> assuming your property sheet defines a property myparent and it is available in the REQUEST (in the form for example) object then it should be added at creation time.
Thanks to people from the list, I know I've to make an external method and add the external method manage_afterAdd to the methods of the class.
This is how the method looks:
This one have not tried before but something along these lines might work: def manage_afterAdd(self,item,container): item.manage_changeProperties({'parent':container.id}) All untested but hopefully helpful Pavlos
participants (3)
-
Kevin Dangoor -
Pavlos Christoforou -
Tom Deprez