Forum OpenACS Development: Re: Modified behavior of templating tags in newer OpenACS versions?

The syntax is not conformant to the tag definitions [1]. I think it was silently introduced a view years ago. There is/was a large variety of styles of Boolean comparison in adp-files, many of those variants were cleaned up, made explicit over the last years [2]. It is not clear, what <if @item_id@> should mean: is it empty (as you suggest? is it non-zero? or is the variable set? So, making these tests explicit helps to understand the code and improves maintainability. Probably, the example above should raise an error/warning, since it is not covered by the OpenACS tag expression rules. I will look into this, when time permits.

If there are many such places in your code basis, you might find the following script helpful for detecting/fixes such cases. Although this script covers for the Boolean cases, it is straightforward to include item_id tests similar as in rule 1. The script works through all the .adp files in the current directory (pr below).

btw,.i would not recommend to upgrade to the beta version (5.9.1b3), but to upgrade to the released version OpenACS 5.9.1.

all the best


#!/usr/bin/env tclsh
# script to change boolean tags
# Gustaf Neumann,   Dez 2010

array set opt {-reset 0 -change 1 -path . -name *adp -diff 0}
array set opt $argv

if {$opt(-reset)} {
    foreach file [exec find -L $opt(-path) -type f -name *-original] {
        regexp {^(.*)-original} $file _ new
        file delete $new
        file rename $file $new

if {$opt(-diff)} {
    foreach file [exec find -L $opt(-path) -type f -name *-original] {
        regexp {^(.*)-original} $file _ new
        set status [catch {exec diff -wu $file $new} result]
        puts "---diff -wu $file $new"
        puts $result

if {$opt(-change)} {
    set totalchanges 0
    set files 0
    foreach file [exec find -L $opt(-path) -type f -name $opt(-name)] {
        puts processing-$file
        set F [open $file]; set c [read $F]; close $F
        set origContent $c
        set newFile ""
        set changes 0

        incr changes [regsub -all {<if @([a-zA-Z0-9_.]+_p)@>} $c {<if @\1;literal@ true>} c]
        incr changes [regsub -all {<if @([a-zA-Z0-9_.]+_p)@ eq ("t"|t|"1"|1)>} $c {<if @\1;literal@ true>} c]
        incr changes [regsub -all {<if @([a-zA-Z0-9_.]+_p)@ eq ("f"|f|"0"|0)>} $c {<if @\1;literal@ false>} c]
        incr changes [regsub -all {<if @([a-zA-Z0-9_.]+_p)@ (true|false)>} $c {<if @\1;literal@ \2>} c]

        if {$changes > 0} {
            puts "... updating $file ($changes changes)"
            set F [open /tmp/XXX w]; puts -nonewline $F $c; close $F
            file rename $file $file-original
            set F [open $file w]; puts -nonewline $F $c; close $F
            incr totalchanges $changes
            incr files
    puts "$totalchanges changes in $files files"

Thank you for your answer and the script, which helped a lot in the investigation of the problem.

Meanwhile, I think I have found the related changes. Firstly,

string is true -strict
is now used instead of
at the relevant place in the code.

However, also

isn't as broad as it was in the past and has been "streamlined" to use the Tcl validation.

So, while it would be easily possible to revive the old behavior at these places, I will go the more future-proof road of changing the about the 200 affected files...