Forum OpenACS Improvement Proposals (TIPs): TIP #89: Define a callback for package parameters

The purpose of this TIP is to suggest the definition of a callback that allows implementors to be informed when ever a package parameter is changed.

The callback interface would be defined in acs-subsite/tcl/subsite-callback-procs.tcl (i.e.):

ad_proc -public -callback subsite::parameter_changed {
   -package_id:required
   -parameter:required
   -value:required
} {
}
The existing proc parameter::set would inform all implementations about the change:
callback subsite::parameter_changed -package_id $package_id -parameter $parameter -value $value
In order to be notified I only need to provide an implementation that for instance logs changes to the parameter I am interested in, for instance for file-storage parameter MaximumFileSize:
ad_proc -public -callback subsite::parameter_changed -impl log_max_f_size_param {
   -package_id:required
   -parameter:required
   -value:required
} {
    Implementation of subsite::parameter_changed to log changes for file-storage paramter MaximumFileSize

    @author Nima Mazloumi (mailto:nima.mazloumi@gmx.de)
    @creation-date 2005-08-17

    @param package_id   the package_id of the package the parameter was changed for
    @param parameter       the parameter name
    @param value      the new value
} {
   # do something intelligent, either a notice in the log or an entry to database or an email to site admin,...
}
Collapse
Posted by Jeff Davis on
I don;t think it should be in the subsite namespace since parameters don't map
in any meaningful way to subsite. Also I am not sure whats easily available
in the parameter::set function but I would think we would want to provide more
than just those args (ie. if we have a parameter_id we should pass that as well).

Finally, the argument and callback docs should be in the callback decleration
in preference to the callback implementation.

Hello Nima,

well, I don't think we need a callback to log this, rather the APM should *notice* that, and log or send email or so, defining callbacks will require extra code that most developers will not likely do. Comments?

Collapse
Posted by Dave Bauer on
Rocael,

I don't understand your comment. What we want to do is extend the behavior of parameters so we can have a centralized places for a packages "settings" but still enable code to run to do something interesting with the information that the setting has changed.

Collapse
Posted by Nima Mazloumi on
Jeff: I agree but the only reason I used sub site is because the parameter page offered to set parameters of package instances is defined in acs-subsite as well as the parameter::set_value proc. So this is a acs-subsite problem, right?

Roc: Changing parameters is not a daily thing. What happens when a parameter changes application specific. No developer will every need to do extra coding. You only offer a callback implementation if you package depends on values of parameters set in other packages. This is actually very convenient.

Collapse
Posted by Malte Sussdorff on
This is implemented yet noone bothered to approve it (okay, hereby I do approve it).