RE: [Zope] context,container,getParentNode()
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/object 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 returns the "nearest" folder. Here's the code: ------------------------------------- # gets the 'nearest' folder def get_nearest_folder(object): parent = object.getParentNode() if(parent.meta_type != 'Folder'): parent = get_nearest_folder(parent) return parent return get_nearest_folder(context) ------------------------------------- Hope that helps! Bye Karsten
-----Ursprüngliche 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 what 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 )
participants (1)
-
Karsten Kraus