[Zope] Form Action question
McDonnell, Larry
lmcdonnell@protonenergy.com
Wed, 6 Nov 2002 07:38:35 -0500
Thanks Clemens, you're right this will help me with error trapping thanks.
-----Original Message-----
From: Clemens Robbenhaar [mailto:robbenhaar@espresto.com]
Sent: Tuesday, November 05, 2002 6:24 PM
To: McDonnell, Larry
Cc: zope@zope.org
Subject: [Zope] Form Action question
Hi Larry,
[snip description]
... if I understand Your question right, You use the Session to store
a variable 'menu_type', which will determine the object the form submit
is send to. Your problem is:
>
> I have tried different variation but I will get a keyerror or a global
> error. Any pointers would be great.
Hm, maybe post one variation (preferably reduced to a minimal version)
and one error message -- this would help spotting the problem, I guess.
You may alternatively set the action for the form to a Python script,
which investigates the session data and then dispatches to the "right"
DTML Method displaying the selected form.
If you do so, You could do better checks in the script,
if the session variable is set at all or do other logic.
For example You could do:
if not request.SESSION.has_key('menu_type'):
# hm, something is wrong ... handle error, e.g.
raise IndexError, 'session has no key "menu_type"'
else:
form_renderer = getattr(context, menu_type)
return form_renderer()
This may give You more freedom to add debugging hooks to find the
problem Yourself.
Cheers,
Clemens