Forum OpenACS Development: Save output

Posted by xx xx on
I have an expensive adp/tcl pair, that uses input by the user. It creates a 'personal Ad'. The endresult is static until the user decides to update information. I would like to store the resulting HTML in CR.

Instead of serving the output to the browser, I'm looking for ways to store the output after hitting a button.

Are there any examples how to do this? I was looking at adp_parse or rp_internal_redirect but I'm not sure how to set those to my needs (and adp_parse is -private).

Any suggestions/examples would be appreciated.

2: Re: Save output (response to 1)
Posted by Tilmann Singer on
Amazingly enough the templating system is able to do that. Here's a snippet from a working page that requests the survey results page for each user in a loop and writes it to a file. Note that this uses ns_set to manipulate the form values instead of rp_form_put because the latter just appends to existing values, which would break after the second iteration.

    foreach survey_id $survey_ids {
        set form [rp_getform]
        ns_set delkey $form survey_id
        ns_set put $form survey_id 3310
        ns_set delkey $form user_id
        ns_set put $form user_id $person_id
        set parsed_template [template::adp_parse "[acs_root_dir]/packages/survey/www/admin/one-respondent" {}]


        set f [open "$user_dir/survey_${survey_id}.html" w]
        puts $f $parsed_template
        close $f
No idea of the db_release_unused_handles call is necessary, I'm not sure if it solved the problem that once came up but it doesn't hurt so I left it in.
3: Re: Save output (response to 2)
Posted by xx xx on
You're awesome. You make things easy, thanks.