[Zope] initlevel at initialization of product with aq_parent
Jens Vagelpohl
jens@zope.com
Fri, 19 Jul 2002 09:08:16 -0400
there is no acquisition context while in __init__. look at
"manage_afterAdd" instead, which gets called after initialization.
jens
On Friday, July 19, 2002, at 08:30 , Nico de Boer wrote:
>
> Hi all,
>
> I'm working on a product that renders treemenu's for websites. Now I
> have to get an initlevel as starting point for my menu.
>
> I've tried the following:
>
> def __init__(self, id, title='', initlevel=0):
> """initialize a new instance of SiteNav"""
> self.id = id
> self.title = title
> self.initlevel = self.getInitLevel()
>
> def getInitLevel(self):
> """returns the initlevel"""
> initlevel = 0
> parent = self
> while 1:
> if hasattr(parent,'aq_parent'):
> parent=parent.aq_parent
> initlevel = initlevel + 1
> else:
> break
> return initlevel - 1
>
> When I add a SiteNav object (folderish object) and I put a DTMLMethod
> in it where I call getInitLevel, I get the correct initlevel.
>
> But when I ask for initlevel in the DTMLMethod, I get -1.
>
> Doesn't the object has a aq_parent at initialization?
>
> Is there a way to do this?
>
> Thanx!
>
> Greetz Nico
>
>
> _______________________________________________
> 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 )