Hello, I wrote the follow python script: from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE return request.PARENTS[0]['menu_array'] And I have had the follow error: Error Type: TALESError Error Value: exceptions.KeyError on menu_array in "standard:'here/getMenuArray | default'", at line 22, column 1 It's right. The request.PARENTS[0] has no menu_array object, but, look the help of __getitem__(id) of objectmanager "Returns a child object given a child id. If there is no child with the given id, returns None. This method makes it easy to refer to children that have id with file extensions. For example:" I think the help is wrong. Is it true? What the best way to solution it? Do I have to use try: catch:? Is there a function for test id, like has_key for dictionary? Regards -- Marco Catunda
Marco Catunda writes:
.... It's right. The request.PARENTS[0] has no menu_array object, but, look the help of __getitem__(id) of objectmanager
"Returns a child object given a child id. If there is no child with the given id, returns None. This method makes it easy to refer to children that have id with file extensions. For example:"
I think the help is wrong. Is it true? Yes, it is obviously wrong.
What the best way to solution it? Do I have to use try: catch:? A "try: ... except KeyError: ..." around the access.
Dieter
participants (2)
-
Dieter Maurer -
Marco Catunda