Forum OpenACS Q&A: Queries in compiled templates

Collapse
Posted by Roberto Mello on
Hi all,

I have an application where I need to call a function that will:

  • setup a db_multirow query
  • compile and eval a template that uses the query
  • return the eval'd html

    The body of my function basically looks like this:

    db_multirow cc_onfile get_creditcards_onfile {} {
         set pretty_creditcard_type 
             [ec_pretty_creditcard_type $creditcard_type]
    } if_no_rows {
         set customer_can_use_old_accounts 0
    }
    
    # Compile and evaluate the template
    set code [template::adp_compile -file
    "[get_server_root]/packages/payflowpro/www/widgets/select-account.adp"]
    return [template::adp_eval code]
    

    But I'm getting a "can't read "cc_onfile:rowcount": no such variable" error, and I'm not sure why. Is there any templating system intricacy that I'm not aware of?

    Thanks in advance.

  • Collapse
    Posted by Roberto Mello on
    Arjun found the issue on this one:

    I needed the "-local" switch for db_multirow, which causes the variables defined by the query to be set locally.

    The -local switch is not documented on the api documentation or on the developers guide. I'm changing that right now 😊