[Kss-devel] the new kssSubmitForm action parameter

Balazs Ree ree at ree.hu
Tue May 1 12:35:18 CEST 2007


With the help of Martin Aspeli, Jan Murre and Godefroid Chapelle and 
others, we introduced a "new way" of submitting entire forms.

The previous solution involved usage of the form() and currentForm() 
action parameters and marshalled an entire form into a single record 
parameter. This breaks to work with Zope list: record: records: style 
multi variables, and it can't even be fixed like this. So we will 
deprecate this usage and have implemented a new way of doing this.

There is a special "action parameter" with the name kssSubmitForm. Action 
parameters are special parameters that are associated with the action 
itself and generic to all actions. Their names all start with the kss 
prefix and consequently normal parameters cannot have their name started 
like this. Other examples of action parameters implemented so far, are 
kssSelector for client actions and kssUrl for server actions.

The kssSubmitForm parameter, if present in a server action, will cause 
the entire form selected by the value, marshalled up directly into the 
request. Then it can be accessed on the server view - as normally - by a 
method parameter, or by accessing request.form directly. It handles all 
Zope multi-style form fields correctly, as it just passes them around to 
the server without processing.

We will yet consider changing the behaviour that happens when there is a 
field in the form which is also a parameter in kss with the same name. 
Currently, the value from the form will silently overwrite that of kss.

Examples for usage as in kss.demo (look for the full example there):


#fullform-current:click {
    action-server:                             submitFullFormIntoRequest;
    submitFullFormIntoRequest-kssSubmitForm:   currentForm();
}

#fullform-named:click {
    action-server:                             submitFullFormIntoRequest;
    submitFullFormIntoRequest-kssSubmitForm:   form(full2);
}

#fullform-namedbystring:click {
    action-server:                             submitFullFormIntoRequest;
    submitFullFormIntoRequest-kssSubmitForm:   'full2';
}

>From the example it can be seen how the providers form() and currentForm
() are used. A single string is equivalent of using form() with the 
string as parameter.

All the above is for handling entire forms only. For handling individual 
field values, formVar() and currentFormVar() can be used as previously. 
These don't aim at handling multi form variables of Zope, instead they 
require the full name of the form field as in the form.

This improvement is part of the current kss.core 1.2-beta2 release, 
already on Cheeseshop.

-- 
Balazs Ree



More information about the Kss-devel mailing list