Forum OpenACS Development: Intrigued by a Tcl variable scope

Request notifications

Posted by Iuri Sampaio on

Writing a piece of code where a listtemplate is not aware of page variables, I noticed the fact that passing product_ids through include calls do work and the values show in the ADP page. However, there are no such variables within listtemplate's scope.

i. passing product_ids through the include:

<include src="/packages/evex-event/lib/events" product_ids="@product_ids@">
ii. As expected, the value of product_ids arrives in .../lib/events, and showed in the browser (adp file) ex.
<listtemplate name="events"></listtemplate>
However, when used within a listtemplate it returns "no such variable". See the chunk of code written in the ad_proc template::list::create
action {
            label "Acoes"
            display_template {
                <button class="button-add" id="button-proposal" 
                 onclick="javascript:window.location.replace('send-proposal?event_id=@events.event_id@&product_ids=@product_ids;noquote@ ');">
                <if events.admin_p>
Does that mean db_multirow's scope isn't aware of page variables?

How do I bring the page variables into listtemplate's scope?

[07/Aug/2018:23:02:38][2470.7f65ca7fc700][-conn:evex:3:3883-] Error: Error in include template "/var/www/evex/packages/evex-event/lib/events": can't read "product_ids": no such variable
    called from adp_parse_ad_conn_file
    called from rp_serve_concrete_file /var/www/evex/packages/evex-event/www/request-proposal.adp

Posted by Iuri Sampaio on
Thanks Gustaf,

It turned out that I change the approach and wrote another script. I've added a form, and the variable is within a hidden input. Instead of an argument in the link, which now is the submit form button and holds another id.

I guess those 3 lines below explain much better what I've written above.

 <form method="post" name="request_proposal" action="request-proposal-2" >
       <input type="hidden" name="product_id" id="product_id" value="@product_id;noquote@" >
       <include src="/packages/evex-event/lib/events" >

Posted by Iuri Sampaio on
Thanks again Gustaf,
I've got another scenario to use list::create -pass_properties.
It works very well.

list::create \
-name events \
-multirow events \
-pass_properties { admin_p } \