Hi,

I've been mucking around with .tml, and discovered (to my toe-curling delight) 
that all files ~/.tml on the path between root and the .tml file being 
expanded are sourced into the interpreter before the .tml subst is done.  I'm 
continually impressed by the code-convenience of tclhttpd, well done.

Anyway, for my app, it'd be nice to have a per-directory prolog, and epilogue 
(respectively) pre- and appended to the .tml contents.

Additionally, I need something which will trap errors and perform some 
cleanups prior to completion (otherwise I leave db queries around in threads, 
and it gets messy.)

So I wrote this little diff to doc.tcl, which will call and insert the results 
of procs pre_subst {script} and post_subst {script} into the .tml's output.

Additionally, there's a proc on_error {code errorCode errorInfo $html} called 
whenever a .tml gets an error.

Of course, if any of these procs doesn't exist in the interpreter there's no 
change to current behavior, but one can define them in the .tml, or in some 
./.tml and have the behaviors described.

Suitable for at least 3.0.[34]

Colin.

738a739,745
>       if {[interp eval $interp info proc on_error]} {
>           global errorCode errorInfo
>           set code [catch {interp eval $interp on_error $code $errorCode $errorInfo 
>$html} html]
>       }
>     }
> 
>     if {$code != 0} {
894c901,908
<       set result [interp eval $interp [list subst $script]]
---
>       set result ""
>       if {[interp eval $interp info proc pre_subst]} {
>           append result [interp eval $interp [list pre_subst $script]]
>       }
>       append result [interp eval $interp [list subst $script]]
>       if {[interp eval $interp info proc post_subst]} {
>           append result [interp eval $interp [list post_subst $script]]
>       }

Reply via email to