Forum OpenACS Improvement Proposals (TIPs): TIP #144 Package Parameter Validation

Package parameters have never had any validation and I have written code to do this with callbacks and ad_form. Any objections to including this in core?
Collapse
Posted by Torben Brosten on
Is there a way to bypass validation?

Bypassing may be necessary for some cases, where for example, the parameter contains a list with one or more elements containing spaces, or a fragment of code etc.

Collapse
Posted by Ryan Gallimore on
If you want to bypass validation, don't create a callback implementation for that parameter. Otherwise, validate the parameter value just like any other ad_form validation.
Collapse
Posted by Torben Brosten on
Ryan,

Can you show an example of how the code would be implemented?

Collapse
Posted by Ryan Gallimore on
Hi Torben,

Here is the patch, which includes an example.

Cheers,
Ryan

Collapse
Posted by Dave Bauer on
How about keying the implementation off the package key?

Then you can have one implementation per package that can validate all the parameters for that package.

Is that better or is having arbitrary implementations better for flexibility? The example seems to suggest keying on package key would simplify things.

Collapse
Posted by Ryan Gallimore on
Keying by package key instead of package id makes sense. The implementation body does not actually need to know the package key, it just needs to call the right package implementation.

So you could call:

callback -impl validate_${package_key} \
subsite::parameter_validate \
-parameter SubsiteSearchP]

which would return a validation list for inclusion into ad_form. I may have to catch the line above in case the package implementation doesn't exist yet.

The implementation for search would just include the validation code for search parameters (see the switch in attached patch).

Collapse
Posted by Ryan Gallimore on
We discussed this in OCT and it was determined that future plans to harmonize the templating system datatypes and acs-kernel datatypes will provide some built in validation of parameters. Since this is a larger project, the prospect of Package Parameter Validation was deferred until the larger type harmonization project is completed.