[Zope] context,container,getParentNode()
Karsten Kraus
Karsten.Kraus@swr3.de
Thu, 23 Aug 2001 13:14:55 +0200
Hi Horst,
as I'm a newbie to zope, I'm not to sure, if I got it right...
'context' stands for the current namespace depending on the document/obje=
ct
a python script
was called form.
Example:
document: /test/testdoc
<dtml-var "doThis()"> // now context.getId() should return testdoc
<dtml-in "objectValues">
<dtml-var "doThat"> // now context.getId() should return the Id of each
child-object (or nothing, if its a doc)
</dtml-in>
container stands for the folder, the script is definied in.
I had simliar problems when calling methods from an instance of a product=
,
so I wrote a function
which gets the parent-object and checks if it's a folder. Finally it retu=
rns
the "nearest" folder.
Here's the code:
-------------------------------------
# gets the 'nearest' folder
def get_nearest_folder(object):
parent =3D object.getParentNode()
if(parent.meta_type !=3D 'Folder'): parent =3D get_nearest_folder(paren=
t)
return parent
return get_nearest_folder(context)
-------------------------------------
Hope that helps!
Bye
Karsten
> -----Urspr=FCngliche Nachricht-----
> Von: zope-admin@zope.org [mailto:zope-admin@zope.org]Im Auftrag von
> Horst Wald
> Gesendet: Donnerstag, 23. August 2001 11:12
> An: zope@zope.org; website-talk-admin@list.ora.com
> Betreff: [Zope] context,container,getParentNode()
>
>
> Hi!
>
> I never really understood the difference between context and
> container. Now
> please don't write "look it up in the documentation", because that's wh=
at
> I've been doing for the last days.
>
> What I'm trying to do is write a python-script that returns the
> parent-folder of the folder from where it has been called. Neither
>
> return context.getParentNode() nor return
> container.getParentNode() seem to
> work.
>
> Horst
>
>
> _________________________________________________________________
> Downloaden Sie MSN Explorer kostenlos unter
> http://explorer.msn.de/intl.asp
>
>
> _______________________________________________
> 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 )