Forum OpenACS Improvement Proposals (TIPs): Re: Tip #18 (Proposed): search order for master tag

Collapse
Posted by Tom Jackson on

Looking over Vinod's patch, I noticed he uses [ns_info server] and comparing that to a part of the url. I think instead he could compare the remaining path to [acs_root_dir], to insure it works in all cases.

I'm working on a patch that handles the bug of comparing the value of the src attribute with the empty string, as opposed to the value of any expression in the src attribute.

The relevant part, untested yet, of Vinod's work is:

      set acs_root_dir [acs_root_dir]

      # are we at acs_root_dir?
      while {![string equal "$cur" "$acs_root_dir"]} {
	  # look for master.adp here
	  if [file exists "${cur}/master.adp"] {
	      # found it
	      set src "${prefix}master"
	      break
	  } 
	  # move up and try again
	  append prefix "../"
	  set cur [file dirname $cur]
      }
Collapse
Posted by Tom Jackson on

I've spent even more time today trying to rid the master tag of the src bug. Again, this is a problem if you pass in a variable, either simple @a@ or array type: @a.b@, where the value of this variable is the empty string.

Well it turns out to be a very stick issue. It isn't at all easy to tell if the value is null.

In reference to the patch by Vinod. This is important for consideration of the method of choosing the master. The master tag is _not evaluated_ on every request! In fact it is evaluated once per thread, per unique url. That means you cannot calculate which master template to use inside the master tag, and then pass this hard coded value along.

I recommend a separate procedure for calculating the master template, and then pass the calculated value into the master tag by using one of the template variable types. Developers can then choose, dynamically, which template to use. This will also make it much easier to debug any template errors,or master template location errors which will show up.

An example of what could happen is that you could add a master template after the server starts up, and after the path to the master had been hard coded into the compiled master tag. The server will still use the old value until a restart.

Any procedure which is used to calculate the master template must always return a value. A null value will result in a very hard to track bug.