[Zope] Classes

Shalabh Chaturvedi shalabh@pspl.co.in
Mon, 28 Feb 2000 18:17:43 +0530


I think I understand what you want. And I have it solved!

There is a hook provided by Zope for such a thing. It's called manage_afterAdd.
Whenever any object is added to a container, the manage_afterAdd method of the
_object_ is called with some parameters.  What you can do is define an external
method called manage_afterAdd in the 'methods' tab of your ZClass:

Define the function like so:

def manage_afterAdd(self,item,container):
    item.myparent=container.id
    return

I have this working here, so its tested. Now, the myparent property of any
object I create or move is always the id of the folder it is in.

Hope this helps,
Shalabh

----- Original Message -----
From: Tom Deprez <tom.deprez@uz.kuleuven.ac.be>
To: Shalabh Chaturvedi <shalabh@pspl.co.in>; <zope@zope.org>
Sent: Monday, February 28, 2000 4:53 PM
Subject: Re: [Zope] Classes


> This is what I'm trying to achieve :
>
> A ZClass when added, fills some properties according to where it is created.
> eg. a propety called Parent. When the instance of the class is created, it
> looks for its parent-name and puts that name in the property 'Parent'.
> When the instance is moved, it should look again for the name of its parent
> (because the parent is changed) and thus change it's property 'Parent'.
>
> (this is a dumb example, but I think it illustrates what I want to achieve).
>
> Thanks in advance,
> Tom.
>
> At 16:50 28/02/2000 +0530, Shalabh Chaturvedi wrote:
> >From: Tom Deprez
> >> Hi,
> >>
> >> Is there a view which allows you to map a method to the creation of a
> class?
> >> (eg, like we map a propertiesform to the properties view)
> >>
> >> ie. A method which is operated when a class is created?
> >>
> >> Thanks in advance,
> >>
> >> Tom.
> >
> >What exactly do you want to do ?
> >
> >If you're working with ZClasses, I think what you want is the Factory.
> When you
> >add a 'Zope Factory' to Product, you really associate a method with an
> item in
> >the ubiquitous drop down 'add' list.
> >
> >Hope this helps.
> >
> >Shalabh
> >
> >
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )