Forum OpenACS Development: Re: Modify function and parameters called by .init function

Hello.

Yesterday I tried to change the version of package and then restart the server but all continue to work as before.

This what I add to -init.tcl function to repeat a task:

ad_schedule_proc \
-schedule_proc ns_schedule_daily \
[list 0 0] im_daily_repetitive_task

The im_daily_repetitive_task function is:

set comando "select id_delay, script, document_id
from im_delayed_tasks, im_categories
where category='Daily' and
category_id=period;"

set toDel [list]
db_foreach del_task $comando {

set aggiorna "${script} -id ${document_id}"
set cancella [eval $aggiorna]
if {$cancella == 1} {
lappend toDel $id_delay
}
}

foreach elem $toDel {

db_dml delElement \
"delete from im_delayed_tasks
where id_delay=${elem};"
}

This function is a -proc.tcl that I inserted in the watch. It take from database all elements in a table and call the function (script) the the element (document_id).

This is the function called:

set numMaxDays [ad_parameter -package_id \
[im_package_invoices_id] \
MaxDelayOfBillFromPO "" 0]

if {$numMaxDays == 0} {
return 0
}

set comando \
"select date_part('day', now() - effective_date) as curDelay
from im_costs
where cost_id=${id};"
set curDays [db_string calcCurDelay $comando -default 0]

set comando "select id_bill from im_link_orders_bills where id_order=${id};"
set id_bill [db_string findBill $comando -default ""]

if {$id_bill == ""} {

if {$numMaxDays < $curDays} {

set comando \
"update im_link_orders_bills set overlimit='t'
where id_order=${id};"
db_dml modOrder $comando

return 1

} else {

return 0
}

} else {

return 1
}

This function is a -proc.tcl file of one other package. I tested this function and it execute how I like but the previous function continue to see the old version of this function where (for example) I forgot "where id_order=${id}" clause.

How you see all code is tcl. Only the name of first function is in the database (but just the name, not the body). The parameter is a parameter of package.

I thought to put all (code and parameter) in the database so the command that I add in the -init.tcl file read directly what it have to execute. Maybe so can execute what I like.

Thank you very much for your help.

Best regards,

Andrea