I found the same problem. I run tclhttpd v. 2.3.5, and applied the
attached patch to lib/doc.tcl.
On another note, I had to make a change to bin/httpd.tcl. I swapped the
two lines:
id userid $uid
id groupid $gid
to be:
id groupid $gid
id userid $uid
since my server is invoked by root:root, and I want it to run as
user:grp. That user does not have privileges to change group from root
to grp.
On Wed, 9 Aug 2000, petrus vloet wrote:
>Dear Lady, Dear Sir,
>
>Did not investigate why it happens, can only tell you that it happens.
>
>I asked one of the students to investigate HTML+tcl Templates.
>
>He set up a simple directory structure with some ....tml and .tml files
>
>All stuff was lying in the root directory ( See below)
>
>/a/.tml
>
>/a/b/.tml
>
>/a/cc.tml
>
>/a/b/dd.tml
>
>In this case the stuff worked fine.
>
>Now we brought the same structure to a users directory "public_html".
>
>Now all stuff should be accessible like this:
>
>~user/a/b/dd.html
>
>It is but only after you
>
>accessed /a/b/dd.html or /a/cc.html.
>
>So it seems as if packages in libtml are not loaded in the case ...tml files
>
>are lying in a user directory.
>
>Q 1: Does tclhttpd only support the HTML+tcl Template mechanism in the case the
>corresponding
>
>files are lying in "docRoot" ?
>
>Q 2: Does the same "problem" also exist for *.tml files in addRoot directories?
>
>Q 3: Will support tclhttpd the HTML+tcl Templates also for the user directories in
>the future ?
>
>Key parameters.
>
>Solaris2.5.1
>
>No threads
>
>tclhttpd3.0.2
>
>tclsh8.3.1
>
>--
>#-------With best regards, Mit freundlichen Gruessen, Met vriendelijke groet,
>------
># Piet Vloet
># Siemens AG Austria
># Boschstrasse 10 Phone : +43-51707-42906
># A-1190 Vienna Fax : +43-51707-52606
># mailto:[EMAIL PROTECTED] WWW:http://www.siemens.at
>
>
>
--
Glenn Jackman
*** doc.tcl~ Tue Oct 26 00:17:58 1999
--- doc.tcl Wed Aug 9 11:39:21 2000
***************
*** 368,380 ****
}
if {[string length $newest]} {
if {[string compare $Doc(tmlSuffix) [file extension $newest]] == 0} {
! foreach try [list [file root $newest].html [file root $newest].htm] {
! if {[file exists $try]} {
! # Ask for .html so it gets generated from the template
! set newest $try
! break
! }
! }
}
# Don't cache translation this to avoid latching onto the wrong file
return [DocHandle $newest $suffix $cookie $sock]
--- 368,382 ----
}
if {[string length $newest]} {
if {[string compare $Doc(tmlSuffix) [file extension $newest]] == 0} {
! # foreach try [list [file root $newest].html [file root $newest].htm] {
! # if {[file exists $try]} {
! # # Ask for .html so it gets generated from the template
! # set newest $try
! # break
! # }
! # }
! # Always ask for .html so it gets generated from the template
! set newest [file root $newest].html
}
# Don't cache translation this to avoid latching onto the wrong file
return [DocHandle $newest $suffix $cookie $sock]
***************
*** 545,561 ****
upvar $dynamicVar dynamic
global Doc
- # Look for .tml library files down the hierarchy.
-
- set rlen [llength [file split $Doc(root)]]
- set dirs [lrange [file split [file dirname $template]] $rlen end]
-
# Populate the global "page" array with state about this page
-
- set root ""
- foreach d $dirs {
- append root ../
- }
if {[string length $htmlfile]} {
set filename $htmlfile
set dynamic 0
--- 547,553 ----
***************
*** 569,575 ****
url $data(url) \
template $template \
filename $filename \
! root $root \
dynamic $dynamic \
set-cookie {} \
]]]
--- 561,567 ----
url $data(url) \
template $template \
filename $filename \
! root $Doc(root) \
dynamic $dynamic \
set-cookie {} \
]]]
***************
*** 612,621 ****
# Source the .tml files from the root downward.
! set path $Doc(root)
! foreach dir [concat [list {}] $dirs] {
! set path [file join $path $dir]
! set libfile [file join $path $Doc(tmlSuffix)]
if {[file exists $libfile]} {
interp eval $interp [list uplevel #0 [list source $libfile]]
}
--- 604,610 ----
# Source the .tml files from the root downward.
! foreach libfile [DocGetTemplates $template] {
if {[file exists $libfile]} {
interp eval $interp [list uplevel #0 [list source $libfile]]
}
***************
*** 763,775 ****
}
# Look for .tml library files down the hierarchy.
! set rlen [llength [file split $Doc(root)]]
! set dirs [lrange [file split [file dirname $template]] $rlen end]
!
! set path $Doc(root)
! foreach dir [concat [list {}] $dirs] {
! set path [file join $path $dir]
! set libfile [file join $path $Doc(tmlSuffix)]
if {[file exists $libfile] && ([file mtime $libfile] > $mtime)} {
return 1
}
--- 752,758 ----
}
# Look for .tml library files down the hierarchy.
! foreach libfile [DocGetTemplates $template] {
if {[file exists $libfile] && ([file mtime $libfile] > $mtime)} {
return 1
}
***************
*** 800,802 ****
--- 783,827 ----
proc Doc_Subst {sock path {interp {}}} {
Httpd_ReturnData $sock text/html [DocSubst $path $interp]
}
+
+
+ # return a list of .tml files that need to be sourced for a template
+ proc DocGetTemplates {template} {
+ global Doc
+
+ # always source the .tml in the rootdir
+ set tmls [list [file join $Doc(root) $Doc(tmlSuffix)]]
+
+ set tmpldirs [file split [file dirname $template]]
+
+ if {0 == [string compare \
+ $Doc(root) \
+ [string range $template 0 [expr {[string length $Doc(root)] - 1}]]]} {
+
+ # the template is in a subdir of $Doc(root)
+ set path $Doc(root)
+ foreach dir [lrange $tmpldirs [llength [file split $Doc(root)]] end] {
+ set path [file join $path $dir]
+ lappend tmls [file join $path $Doc(tmlSuffix)]
+ }
+ } else {
+
+ # check if the template is under the user's homedir
+ set hindex [lsearch -exact $tmpldirs $Doc(homedir)]
+ if {$hindex == -1} {
+ # nope
+ lappend tmls [file join [file dirname $template] $Doc(tmlSuffix)]
+ } else {
+ # this template is under the user's homedir
+ set path [eval file join [lrange $tmpldirs 0 $hindex]]
+ incr hindex
+ foreach dir [concat [list {}] [lrange $tmpldirs $hindex end]] {
+ set path [file join $path $dir]
+ lappend tmls [file join $path $Doc(tmlSuffix)]
+ }
+ }
+ }
+ return $tmls
+ }
+
+