Forum OpenACS Q&A: Response to host / site-node map

Collapse
Posted by Alex Sokoloff on

Ben asked

- is anyone extensively using host site node mapping? I've found many bugs in the way it works and am wondering if my initial fixes (specifically in directory redirection and index file redirection) are worth uploading, or if we should just let the host side node map stuff die (as it is quite horrendous as is).

We'll probably be using it for parts of Greenpeace Planet, if it doesn't misbehave too badly. Being able to map, say, www.greenpeace.nl to www.greenpeace.org/nederland solves a bunch of problems with how Google indexes regional subsites. Ben, if you're not going to commit your fixes, could you send them along my way?

I found a problem that perhaps Ben did too. There's a tweak in rp_filter that Don added right after the hostname-based subsites patch:

    # DRB: a bug in ns_conn causes urlc to be set to one and urlv to be set to
    # {} if you hit the site with the host name alone.  This confuses code that
    # expects urlc to be set to zero and the empty list.  This bug is probably due
    # to changes in list handling in Tcl 8x vs. Tcl 7x.

    if { [ad_conn urlc] == 1 && [lindex [ad_conn urlv] 0] == "" } {
        ad_conn -set urlc 0
        ad_conn -set urlv [list]
    }

It turns out that the same problem crops if you hit the site with a mapped hostname alone, so you need a different tweek. Something like this:

    if { [ad_conn urlc] == 1 && [lindex [ad_conn urlv] 0] == "" } {
        ad_conn -set urlc 0
        ad_conn -set urlv [list]

    } elseif { [ad_conn urlc] > 1 && [lindex [ad_conn urlv] end] == "" } {

        ad_conn -set urlc [expr [ad_conn urlc] - 1]
        ad_conn -set urlv [list [lreplace [ad_conn urlv] end end]]
    }

I haven't had a chance to test this extensively as of yet.