[plt-scheme] Re: Shared resources for servlets
I suspect that the web server is being clever. If you were to load
those modules in mzscheme, you wouldn't see two printouts. Probably
something the current web server maintainers should look into. Seems
buggy to me.
Robby
At Tue, 09 Sep 2003 13:11:57 -0500, David Van Horn wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Keith Frost wrote:
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> > If I'm not mistaken, you've answered your own question: just use a
> > module. When subsequent servlets 'require' the same module, it is not
> > reloaded, and
> > any local state in the module is preserved.
>
> I don't think so...
>
> Basically I have a module A that I want each servlet to have access to the
> bindings of. The body of A has expressions evaluated for side-effects that I
> want to evaluate only once, when the server is started (or the first servlet
> is loaded).
>
> If B and C are servlets that require A, the side-effects are produced when B
> is loaded and again when C is loaded.
>
> ;; a.ss
> (module a mzscheme
> (printf "side-effect of A\n"))
>
> ;; b.ss
> (module b mzscheme
> (require "a.ss")
> (provide interface-version timeout start)
> (define interface-version 'v1)
> (define timeout +inf.0)
>
> ; start : request -> response
> (define (start initial-request)
> `(html (body (p "loaded")))))
>
> ;; c.ss -- same as b
>
> This prints two "side-effect of A"s.
>
> I feel like I'm totally missing the broad side of a barn here. Thanks for the
> help.
>
> -d
>
>