All, After looking through the list for the last hour I could not find an answer to the following problem. I have a dtml form that itterates over the content of a folder and displays a checkbox next to each of the files. The form allows a user to select items to be deleted. If a user does not select a check box I get the folloewing error: Error Type: NameError Error Value: global name 'ids' is not defined This only happens when a checkbox has not been selected. here is the form calling a method: <FORM ACTION="delete" method="POST"> <dtml-in "objectValues(['File'])" sort=id> <INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<dtml-var id>"> <dtml-var id><p> </dtml-in> <INPUT TYPE="SUBMIT"> </form> Regards, Rob Grissom
Rob - The problem isn't in the form, it's in the 'delete' method. This needs to check if 'ids' exists. If you post the 'delete' method you'll get some help on that. Andrew -- Logical Progression Ltd, 20 Forth Street, Edinburgh EH1 3LH, UK Tel: +44 (0)131 550 3733 Web: http://www.logicalprogression.net/
From: <grissom@qwickconnect.net> Date: Tue, 26 Aug 2003 07:00:12 -0700 To: zope@zope.org Subject: [Zope] ids NameError
All,
After looking through the list for the last hour I could not find an answer to the following problem.
I have a dtml form that itterates over the content of a folder and displays a checkbox next to each of the files. The form allows a user to select items to be deleted. If a user does not select a check box I get the folloewing error:
Error Type: NameError Error Value: global name 'ids' is not defined
This only happens when a checkbox has not been selected.
here is the form calling a method:
<FORM ACTION="delete" method="POST"> <dtml-in "objectValues(['File'])" sort=id> <INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<dtml-var id>"> <dtml-var id><p> </dtml-in> <INPUT TYPE="SUBMIT"> </form>
Regards,
Rob Grissom
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
I have a dtml form that itterates over the content of a folder and displays a checkbox next to each of the files. The form allows a user to select items to be deleted. If a user does not select a check box I get the folloewing error:
Error Type: NameError Error Value: global name 'ids' is not defined
This only happens when a checkbox has not been selected.
here is the form calling a method:
<FORM ACTION="delete" method="POST"> <dtml-in "objectValues(['File'])" sort=id> <INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<dtml-var id>"> <dtml-var id><p> </dtml-in> <INPUT TYPE="SUBMIT"> </form>
When you do an HTTP POST or GET a form parameter is only sent for a checkbox if that checkbox is checked. Nothing is done if it is unchecked. Yes, this is a little silly, but we have to deal with it. In any case, you can never rely on a request from a web environment to be well-formed. You need to check in the destination script ('delete') for existence of 'ids', and do the appropriate thing if it does not exist. This may be as simple as:: if not ids: ids = [] Or maybe you have different logic if there's no contents. Since you're deleting from a list (presumably) you can probably just skip the whole part where you delete things. --jcc
grissom@qwickconnect.net wrote at 2003-8-26 07:00 -0700:
After looking through the list for the last hour I could not find an answer to the following problem.
I have a dtml form that itterates over the content of a folder and displays a checkbox next to each of the files. The form allows a user to select items to be deleted. If a user does not select a check box I get the folloewing error:
Error Type: NameError Error Value: global name 'ids' is not defined
This only happens when a checkbox has not been selected.
Add a <input type=hidden name="ids:tokens:default"> to your form. Read section 2.6.3 of <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> to learn why it works. Dieter
participants (4)
-
Andrew Veitch -
Dieter Maurer -
grissom@qwickconnect.net -
J Cameron Cooper