[plt-scheme] Web server + serialze problem

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 3 09:25:00 EDT 2005

At Tue, 3 May 2005 01:14:50 -0400, Alexander Friedman wrote:
> BUT, if this servlet is run from the web server:
> 
> deserialize-info-maker: expects args of type
> <struct:deserialize-info>; given instance of a different
> <struct:deserialize-info>
> 
> What gives?

The problem is that the web server creates a new namespace to load each
module-based servlet, but it doesn't make that namespace the current
one whenever it runs the servlet. The `dynamic-require' inside
`deserialize' therefore accesses the wrong instance of the servlet
module.

I haven't tried it, but I expect that you can work around the
web-server problem by capturing and re-installing the namespace:

  (define start
    (let ([ns (current-namespace)])
      (lambda (req)
        (parameterize ([current-namespace ns])
          (deserialize (serialize (make-foo)))))))

Meanwhile, I'll file a web-server bug report.

Matthew



Posted on the users mailing list.