Hello all again: I have a Folder named A: A contains an object obja with 2 methods (methoda, methodb). A contains a Folder named B also. In B exist an object named objb, and in this object I want to use the methoda from the object sited in his parent folder... How I can do this?
On Wednesday 17 October 2001 12:48 pm, Antonio Beamud Montero allegedly wrote:
Hello all again: I have a Folder named A: A contains an object obja with 2 methods (methoda, methodb). A contains a Folder named B also. In B exist an object named objb, and in this object I want to use the methoda from the object sited in his parent folder...
How I can do this?
objb should have direct access to methoda through acquisition. See: http://www.zope.org/Members/michel/ZB/AdvDTML.dtml http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html#c37ac15c13 for more information hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
On Wed, 2001-10-17 at 20:58, Casey Duncan wrote:
On Wednesday 17 October 2001 12:48 pm, Antonio Beamud Montero allegedly wrote:
Hello all again: I have a Folder named A: A contains an object obja with 2 methods (methoda, methodb). A contains a Folder named B also. In B exist an object named objb, and in this object I want to use the methoda from the object sited in his parent folder...
How I can do this?
objb should have direct access to methoda through acquisition. See:
http://www.zope.org/Members/michel/ZB/AdvDTML.dtml http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html#c37ac15c13
Ok, but I don't want this. I want to do the next: A is Folder with a lot of object instances. from one of this instances I want to had a variable of references to objects in the same folder, but I don't know how to do this. Something like this: Class A(Folder): ... Class x(Implicit, Persistent, PropertyManager, RoleManager, Item): .... __init__(self, id, title): self.myfriends = [] def list_Posible_Friends(self): """ Here I want to know what objects has instantiated my container""" posible_list = self.objectValues() ####################### This action doesn't works like I want to works... ####################### def addFriend(self, Ref): list.append(Ref) How I can do this
On Thursday 18 October 2001 04:59 am, Antonio Beamud Montero allegedly wrote: [snip]
A is Folder with a lot of object instances. from one of this instances I want to had a variable of references to objects in the same folder, but I don't know how to do this.
Something like this:
Class A(Folder): ...
Class x(Implicit, Persistent, PropertyManager, RoleManager, Item): .... __init__(self, id, title): self.myfriends = [] def list_Posible_Friends(self): """ Here I want to know what objects has instantiated my container"""
posible_list = self.objectValues()
####################### This action doesn't works like I want to works... #######################
def addFriend(self, Ref): list.append(Ref)
How I can do this
You can use aq_parent to get the container as in: def list_Possible_Friends(self): possible_list = self.aq_parent.objectValues() However I would caution against storing references to these objects in your x instances (like your code in addFriend implies). This creates a circular reference such that if the object is deleted from thecontainer, it still exists in your instance. This makes it hard to really get rid of an object. This adds another layer of bookkeeping to your application unless you don't care about "leaking" objects this way. hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (2)
-
Antonio Beamud Montero -
Casey Duncan