Conditional inquire: some internal questions

Vladimir Voznesensky <[email protected]> Sat, 04 Oct 2003 18:46:47 +0400
Newsgroups gmane.comp.web.zope.formulator.devel
Message-ID <[email protected]>
Dear Martijn and the folks!
I began to hack Formulator code to add conditional inquire functionality.
My plan is:
1. Add "enabled" field to all widgets.
That means, add "enabled" as a CheckBoxField(..., default=1) to Widget 
class and "enabled" to property_names of this class.
2. Add argument with_disabled=0 to Form.get_fields_in_group() method.
If with_disabled, return all of the group fields including disabled ones.
Else, return all of the enabled group fields.
3. Add the same argument to the following accessors (Form and BasicForm):
get_fields
get_field_ids
has_field (exists and (disabled or enabled))
get_field (throw exception if not has_field)
get_groups (if not disabled, return only groups that has enabled fields)
4. rendering: nothing to change?!
5. validate: That philosophical question: do we need to check the 
existance of disabled fields?
Now I'm not shure that we need it.
The only one (IMHO) warning case here was mentioned in my previous 
letter: the system state can be changed between form rendering and form 
submitting, so TALES enabled expressions changed it's boolean value.
For example.
Imagine, that some geek absent-minded person form a description of a 
sick person. He opened two browser windows with forms of the same person.
a. He leaved field "gender" with value "female".
b. Than, he submitted the first form in a first window and the Zope 
instance rendered a next form to the first window with an additional 
field "gynecologist diagnosis".
c. Than, he switched to the second window, changed field "gender" value 
to "male" and submitted the form in the second window.
d. Than, he filled and submitted additional form in the first window.
There could not be a gynecologist diagnosis for a man, so the Validator 
would just silently ignore "gynecologist diagnosis" field.
If the geek person made changes in reverse order ("male" -> "female"), 
the problem become harder: the Zope instance would expect "gynecologist 
diagnosis", but it would not exisit!

6. Check up dtml for get_fields_in_group, get_fields, has_field, 
get_field, get_groups and add 'with_disabled' argument ", 1" where needed.
The main rule here is that we must show all of the fields in case of 
editing and the form without disabled fields in case of testing.

Something else?

Regards.
VV