Re: [Zope] Form Variables

2005-06-15 Thread J Cameron Cooper

David Ayres wrote:

I've been working around this issue for literally years and finally have the
time to seek a real solution. :) I can't find much information, so I'm
assuming I'm just taking the wrong approach.

Whenever a form is posted, the text fields always show up in the
request.form, however any other type of form element that has not been given
a value does not show up. None of the fields have the ignore_empty
attribute. Besides using the missing= attribute, what other options are
there?

Most of my forms have optional fields and this is especially painful when
trying to use ZSQL Methods or when creating  multipage forms that refer to
earlier form values.


The specifications for forms only require certain successful controls 
to be submitted, and most browsers work this way. This is specially 
noticable with checkboxes, which when on are in the request and absent 
when off. See:


http://www.w3.org/TR/REC-html40/interact/forms.html#successful-controls

Frankly, I consider this behavior bizarre and unhelpful, but there's not 
much to be done about it protocol-side. I would imagine there's a 
hstorical reason.


For use in Zope, keep in mind that parameters for both Python scripts 
and Z SQL Methods allow for default values, so you don't have to rely on 
 a parameter being present in the request. In ZPTs there's conditional 
expressions, and in DTML the 'missing' pseudo-attribute.


--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com
___
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 )


RE: [Zope] Form Variables

2005-06-15 Thread David Ayres
Thanks for the information. I have been pulling my hair out because I have
some lengthy forms (wizards) and it can be harrowing at times. :) I think
the best solution for my situation is to do a JS/CSS tabbed solution, so
it's one form. Are you aware of any limitations on the size of posted data?
I haven't hit any walls yet with respect to that.

Dave

-Original Message-
From: J Cameron Cooper [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 15, 2005 12:05 PM
To: David Ayres
Cc: zope@zope.org
Subject: Re: [Zope] Form Variables


David Ayres wrote:
 I've been working around this issue for literally years and finally have
the
 time to seek a real solution. :) I can't find much information, so I'm
 assuming I'm just taking the wrong approach.

 Whenever a form is posted, the text fields always show up in the
 request.form, however any other type of form element that has not been
given
 a value does not show up. None of the fields have the ignore_empty
 attribute. Besides using the missing= attribute, what other options are
 there?

 Most of my forms have optional fields and this is especially painful when
 trying to use ZSQL Methods or when creating  multipage forms that refer to
 earlier form values.

The specifications for forms only require certain successful controls
to be submitted, and most browsers work this way. This is specially
noticable with checkboxes, which when on are in the request and absent
when off. See:

http://www.w3.org/TR/REC-html40/interact/forms.html#successful-controls

Frankly, I consider this behavior bizarre and unhelpful, but there's not
much to be done about it protocol-side. I would imagine there's a
hstorical reason.

For use in Zope, keep in mind that parameters for both Python scripts
and Z SQL Methods allow for default values, so you don't have to rely on
  a parameter being present in the request. In ZPTs there's conditional
expressions, and in DTML the 'missing' pseudo-attribute.

--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


___
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 )


Re: [Zope] Form Variables

2005-06-15 Thread Tino Wildenhain
Am Mittwoch, den 15.06.2005, 11:27 -0400 schrieb David Ayres:
 I've been working around this issue for literally years and finally have the
 time to seek a real solution. :) I can't find much information, so I'm
 assuming I'm just taking the wrong approach.
 
 Whenever a form is posted, the text fields always show up in the
 request.form, however any other type of form element that has not been given
 a value does not show up. None of the fields have the ignore_empty
 attribute. Besides using the missing= attribute, what other options are
 there?
 
 Most of my forms have optional fields and this is especially painful when
 trying to use ZSQL Methods or when creating  multipage forms that refer to
 earlier form values.
 
 Any suggestions would be greatly appreciated!!

Zope has along with nice type converters, also a workaround
for the checkbox-problem:

http://www.zope.org/Members/Zen/howto/FormVariableTypes

However, working with request.form.get('value',default)
is often more robust.


___
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 )


Re: [Zope] Form Variables

2005-06-15 Thread J Cameron Cooper

David Ayres wrote:

Thanks for the information. I have been pulling my hair out because I have
some lengthy forms (wizards) and it can be harrowing at times. :) I think
the best solution for my situation is to do a JS/CSS tabbed solution, so
it's one form. Are you aware of any limitations on the size of posted data?
I haven't hit any walls yet with respect to that.


I don't think there are any. I know I've posted files over .5Gb in size, 
probably bigger.


--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com
___
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 )


Re: [Zope] Form Variables

2005-06-15 Thread Dieter Maurer
David Ayres wrote at 2005-6-15 11:27 -0400:
Whenever a form is posted, the text fields always show up in the
request.form, however any other type of form element that has not been given
a value does not show up. None of the fields have the ignore_empty
attribute. Besides using the missing= attribute, what other options are
there?

This is as specified by HTML:

   Unchecked check boxes and not selected options are not 
   sent by the browser.

Zope allows you to use suffixes to tell its ZPublisher component
to hande form variables in a special way.

One of these suffixes is :default. It is used in
an 'input type=hidden name=variable:default value=some_value'
to provide a default value for variable.

You find a discription of more of these magic suffixes in

  http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html


-- 
Dieter
___
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 )


Re: [Zope] Form variables with same name as folder names

2000-11-14 Thread Chris Withers

"Burwell, Becky " wrote:
 
 The simple answer:  use REQUEST.form['FOO']  to refer to the
 form variable.
 
 I just did an experiment and if I do the following my SQL Method:
dtml-if REQUEST.form['FOO']
 
 this is never true.

...because you're missing some " "

REQUEST.form['FOO'] is a python expression.

dtml-if REQUEST.form['FOO'] is short for dtml-var
name="REQUEST.form['FOO']"

so, unless you have a folder or document names 'REQUEST.form['FOO']', it
will return false :-S

What you want is dtml-if "REQUEST.form['FOO']", which is short for
dtml-if expr="REQUEST.form['FOO']".

This evaluates expr as a python expression...

 If I do:
 dtml-if "REQUEST.form['FOO']" or dtml-if "REQUEST.form['FOO]=='1'"
 
 I get name errors with REQUEST being unknown.

...an oddity of ZSQL methods :-( The REQUEST usually gets made available
in the namespace, but in ZSQL methods, only the parameters your specify
as 'arguments' get added to the namespace. At a guess, try adding
REQUEST to the 'Arguments' list...

good luck,

Chris

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Form variables with same name as folder names

2000-11-13 Thread Andy McKay

 1) the ZSQL manual,
http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.4.html, says
that the first lookup should be variables in HTTP_REQUEST. So why is FOO
referring to my folder FOO?

Its true it does and I found the exact problem. A chance to lob this bug
into the collector.

 2) is there some way I could have referred to the variable FOO in my Z SQL
method without resorting to renaming the variable in my form?

Rename your folder :)



___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Form variables with same name as folder names

2000-11-13 Thread Curtis Maloney

On Tue, 14 Nov 2000, "Burwell, Becky wrote:
 Hi. I am new to using Zope and just got stuck on the following problem. I
 am trying to use forms with an SQL database.

 I have a form with checkboxes and I use variables like FOO to capture the
 value. For example: input type="checkbox" name="FOO" value="1"

 The form has a post with the action to call a DTML document. In my DTML
 document I call a Z SQL Method called InsertMethod with REQUEST as the
 argument, for example  InsertMethod(REQUEST).

 My Z SQL Method InsertMethod has arguments including
   FOO=""

 And then in the body of the Z SQL method I have:

 dtml-if FOO
{code to insert into a database table}

 
 This working UNTIL I created a Folder named FOO. Then the value of FOO in
 the Z SQL method seemed to be the FOO folder and not FOO from REQUEST.  My
 workaround was to call the variable FOOCHECKBOX.


 2) is there some way I could have referred to the variable FOO in my Z SQL
 method without resorting to renaming the variable in my form?


A sneaky problem indeed, and once again, one caused by "convenient" 
shortcuts. (o8

The simple answer:  use REQUEST.form['FOO']  to refer to the form variable.

The longer answer:

To make life simpler on our key-weary fingers, DC made all the form variables 
part of the namespace, but put then sufficiently down the search path so they 
wouldn't get in the way of other objects.  Most of the time this is just 
great, but occasionaly you do run into this problem.

So, you can explicitly access all form variables with REQUEST.form[]... just 
as you can access all cookies via REQUEST.cookies[] 

I would advise you make a small DTML Document containing dtml-var REQUEST 
just to have a look at what it contains THEN go and check up the ZQR for 
all the members of REQUEST... and RESPONSE, while you're at it.. (o8


 Thanks!

 *becky*


Have a better one,
Curtis Maloney

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Form variables with same name as folder names

2000-11-13 Thread Burwell, Becky [EMAIL PROTECTED]

On Tue, 14 Nov 2000, "Burwell, Becky wrote:

 This working UNTIL I created a Folder named FOO. Then the 
value of FOO in
 the Z SQL method seemed to be the FOO folder and not FOO 
from REQUEST.  My
 workaround was to call the variable FOOCHECKBOX.


 2) is there some way I could have referred to the variable 
FOO in my Z SQL
 method without resorting to renaming the variable in my form?


A sneaky problem indeed, and once again, one caused by "convenient" 
shortcuts. (o8

The simple answer:  use REQUEST.form['FOO']  to refer to the 
form variable.

I just did an experiment and if I do the following my SQL Method:
   dtml-if REQUEST.form['FOO']

this is never true.

If I do:
dtml-if "REQUEST.form['FOO']" or dtml-if "REQUEST.form['FOO]=='1'"

I get name errors with REQUEST being unknown.

The REQUEST.form thing works in the DTML document that calls the SQL method but not
in the SQL method itself.

*becky*

___
Zope maillist  -  [EMAIL PROTECTED]
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 )