Forum OpenACS Improvement Proposals (TIPs): Re: Tip #79 (Implemented) Callbacks

Collapse
Posted by Enrique Catalan on
Hi, Nice development.

I used it but I got an error, I'm not sure if it is a bug but I had problem with *.xql files, apparently the implementations could not read the queries of the .xql file.

I did the "watch file" on the xql files and didn't work then I restarted the webserver and neither, so I copied the query from the .xql and pasted it into the tcl and it worked!.

I defined my callback as follow:

ad_proc -callback MergePackageUser {
    -from_user_id:required
    -to_user_id:required
} {
    Merge two accounts
} {}

One of the implementations is:

namespace eval forum::merge {
    ad_proc -callback MergePackageUser -impl forums {
        -from_user_id:required
        -to_user_id:required
    } {
        Merge the *forums* of two users.
        The from_user_id is the user_id of the user
        that will be deleted and all the *forums*
        of this user will be mapped to the to_user_id.

    } {
        ns_log Notice "Merging forums"

        db_transaction {
            db_dml upd_poster { *SQL* }
            db_dml upd_user_id { *SQL* }
            set result 1
        } on_error {
            ns_log Error "I couldn't merge forums. The error was $errmsg"
            set result 0
        }

        return $result
    }
}

The xql file seems :

    <fullquery name="forum::merge::MergePackageUser.upd_poster">
        <querytext>
        update forums_messages
        set last_poster = :to_user_id
        where last_poster = :from_user_id
        </querytext>
    </fullquery>

    <fullquery name="forum::merge::MergePackageUser.upd_user_id">
        <querytext>
        update forums_messages
        set user_id = :to_user_id
        where user_id = :from_user_id
        </querytext>
    </fullquery>

If I run the same proc but without the callbacks flags it works fine, the problem is only when I add that flags but if I copy the queries to the .tcl file, all work fine.

Did I make a mistake in my code?

Thanks in advance.

Enrique.