You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-user@tcl.apache.org by Jerry Lam <bo...@hotmail.com> on 2003/11/20 22:30:37 UTC
share procedures across multiple pages
Hi,
I wonder if there is any mechanism which allows me to share procedures across multiple pages.
Let say, I have a script called a.wsh, it contains several procedures that are reusable across 1.wsh, 2.wsh and 3.wsh.
so that each wsh sources a.wsh and can use any method defined in a.wsh.
Thanks,
Jerry
Re: share procedures across multiple pages
Posted by Ronnie Brunner <ro...@netcetera.ch>.
> I wonder if there is any mechanism which allows me to share
> procedures across multiple pages.
> Let say, I have a script called a.wsh, it contains several procedures that are reusable across 1.wsh, 2.wsh and 3.wsh.
> so that each wsh sources a.wsh and can use any method defined in a.wsh.
That's what interpreter classes are for: the simplest thing is to
define a single class for all files in the websh.conf file:
web::interpclass {file} {
return /path-to-your/common.wsh
}
Your common.wsh then looks something like:
#---------------------------------------------------------------------
# main application dispatcher
#---------------------------------------------------------------------
# only get the code on the first request
web::initializer {
# this is where all your code sits
web::include /path-to-your/a.wsh
}
# process the actual web page
web::include [web::config script]
This not only shares code amongst your files, but even interpreters.
Depending on your configuration you can reuse interpreters and
therefore even share variables and stuff (which also has some
drwabacks if you don't really know what your doing, especially
concerning sessions and stuff).
hth
Ronnie
----------------------------------------------------------------------
Ronnie Brunner ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich phone +41 1 247 79 79 fax +41 1 247 70 75