Forum OpenACS Development: Amending table apm_package_callbacks

Collapse
Posted by Iuri Sampaio on
When I created a package I wrote a callback to run along with the installation process.

cnauto_core::install::after_instantiate

But later I had to change it to:
cn_core::install::after_install

However, within the table apm_package_callbacks the register is:

228292 | after-instantiate | cnauto_core::install::after_instantiate

Moreover every time I try to mount the application cnauto-core I get the error:

Error: Aborting transaction due to error:
invalid command name "cnauto_core::install::after_instantiate"
[28/Jan/2012:12:08:43][25038.3054685040][-default:4-] Warning: propagating abortion from /var/www/iurix/packages/acs-subsite/www/admin/site-map/package-new.tcl (status 200): 'Problem with Your Input')
[28/Jan/2012:12:08:43][25038.3054685040][-default:4-] Warning: propagating abortion from /var/www/iurix/packages/acs-tcl/lib/page-error.tcl (status 200): 'Problem with Your Input')
[28/Jan/2012:12:08:43][25038.3054685040][-default:4-] Error: rp_report_error: Error rendering error page (!)
ADP_ABORT
while executing
"error ADP_ABORT "
(procedure "adp_abort" line 2)
invoked from within
"adp_abort"
invoked from within
"if { [file exists $__adp_stub.tcl] } {

which in a nicer fashion the message would be:

#######
We had a problem with your input:

Error Creating Package: The following error was generated when attempting to create the package
invalid command name "cnauto_core::install::after_instantiate"

Please back up using your browser, correct the above error, and resubmit your entry.

Thank you.

#######

How would I change the record within the table apm_package_callbacks in order to get rid of the error ?

Basically I created an ad_proc and a plsql function that runs an update query. Although I am not sure if I need to contemplate other references in the OACS core datamodel. Please, see bellow:

ad_proc -private apm_package_callbacks::edit {
{-version_id:required}
{-old_proc:required}
{-old_type:required}
{-new_proc:required}
{-new_type:required}
} {
Updates package's callback info
} {

db_exec_plsql update_info {
SELECT apm_package_callbacks__update (
:version_id,
:old_proc,
:old_type,
:new_proc,
:new_type,
)
}

return
}

CREATE OR REPLACE FUNCTION apm_package_callbacks__update ( integer, varchar, varchar, varchar, varchar, varchar )
RETURNS integer AS '
DECLARE
p_version_id ALIAS FOR $1;
p_old_proc ALIAS FOR $2;
p_old_type ALIAS FOR $3;
p_new_proc ALIAS FOR $4;
p_new_type ALIAS FOR $5;
BEGIN

UPDATE TABLE apm_package_callbacks SET type = p_new_type, proc = p_new_proc WHERE version_id = p_version_id AND proc = p_old_proc;

RETURN 0;

END; language 'plpsql';

Is there other references that I also need to amend?

Anyway,this thread stays as a suggestion to the community to create such kinds of APIs in order to amend, cleanly, OACS core datamodel.

Collapse
Posted by Dave Bauer on
Just go into the APM and change the name of the callback.

If you want to know what calls to make, figure out what happens on the APM admin pages when you add/remove or edit a callback.

Collapse
Posted by Iuri Sampaio on
Dave,

The issue isn't to find an answer. I already have it.

Collapse
Posted by Iuri Sampaio on
I don't want to simply change the proc's name.

In this case it is mandatory to change the register within the table because the name determines exactly when the proc runs, moreover it self-document the code and keeps it more intuitive .

Anyway, the point was the suggestion to create code in order to better administrate such core information and functioalities