The objective of this TIP is to give core the ability to invoke code in non-core packages that may or may not be installed, but without cluttering core with an ever-growing list of "if" statements that check if package X is installed before calling its code.
The larger goal is to promote reuse of standard pages and functions by removing the need to create per-package versions of these. So, for the example case of removing a user, we're proposing this architecture
-> Core proc for removing user
-> Invoke callbacks based on what's installed
-> Package A logic for removing user
-> Package B logic for removing user
-> Package C logic for removing user
...
-> Core logic for removing user
as opposed to this architecture
-> Package A proc for removing user
-> Package A logic for removing user
-> Call core proc for removing user
-> Package B proc for removing user
-> Package B logic for removing user
-> Call core proc for removing user
The specific proposal is to extend ad_proc as follows
- Add a -callback flag to designate the function as a callback system participant (entry point or implementation).
- Add an -implementation flag to designate the function as a callback implementation.
and to add a page to api-doc that lists the available callback entry points.
Once implemented, callback entry points would be declared like this:
ad_proc -callback module::op {
{-option {} }
arg1:required
} {
docs
} -
Note the proc has no body. This proc exists solely to document the inputs and outputs, and so we can build a page documenting the callback entry points.
Callback implementations would be declared like this:
ad_proc -callback module::op -implementation implname { ... }
Note the implementation has the same name as the callback, but also has an -implementation flag and a body. To ensure that callbacks aren't accidentally overwritten, say if a developer forgets the implementation flag, ad_proc will error out if the proc has a -callback flag and a body, but no -implementation flag.
More:
https://openacs.org/forums/message-view?message%5fid=273782