[plt-scheme] Serializing/deserializing in a servlet

From: Eddie Sullivan (eddieSull at hotmail.com)
Date: Mon Dec 1 11:16:53 EST 2008

Thanks, guys, for the replies. I'm not sure I understand the explanation 
about namespaces (since there's only one servelet), but using a prefab 
structure did the trick.
-Eddie

----- Original Message ----- 
From: "Jay McCarthy" <jay.mccarthy at gmail.com>
To: "Robby Findler" <robby at cs.uchicago.edu>
Cc: "Eddie Sullivan" <eddieSull at hotmail.com>; <plt-scheme at list.cs.brown.edu>
Sent: Friday, November 28, 2008 9:32 PM
Subject: Re: [plt-scheme] Serializing/deserializing in a servlet


>I believe that they wouldn't be interfered with by the separate
> namespaces. But if the "real" structs Eddie wants have properties,
> then IIRC, prefab'd structs can't have them.
>
> Jay
>
> On Fri, Nov 28, 2008 at 10:26 PM, Robby Findler <robby at cs.uchicago.edu> 
> wrote:
>> Would a #:prefab struct help?
>>
>> Robby
>>
>> On Fri, Nov 28, 2008 at 11:23 PM, Jay McCarthy <jay.mccarthy at gmail.com> 
>> wrote:
>>> Servlets don't share namespaces, in particular, this means that
>>> servlets can't interact with each other through structs, which are
>>> generative. You can solve this by passing the #:make-servlet-namespace
>>> argument to serve/servlet passing in the module spec of the source of
>>> the struct. I could debug this program tomorrow, but I don't have time
>>> right now.
>>>
>>> Jay
>>>
>>> On Fri, Nov 28, 2008 at 12:45 PM, Eddie Sullivan <eddieSull at hotmail.com> 
>>> wrote:
>>>> Hi.
>>>> The following simple code works well normally, but when run in a 
>>>> servlet
>>>> causes a strange error:
>>>>
>>>> #lang scheme
>>>>
>>>> (require scheme/serialize
>>>>        web-server/servlet-env)
>>>>
>>>> (define-serializable-struct test-struct
>>>>  (a))
>>>>
>>>> (define (test-serialize)
>>>>  (let* ([s (make-test-struct
>>>>           "Eddie Sullivan")]
>>>>        [serialized-s (serialize s)]
>>>>        [new-s (deserialize serialized-s)])
>>>>   (display (format "test-serialize: Saved a: ~a" (test-struct-a
>>>>                                                   new-s)))))
>>>>
>>>>
>>>> (define (go)
>>>>  (serve/servlet start))
>>>>
>>>> (define (start request)
>>>>  (test-serialize))
>>>>
>>>>
>>>> In DrScheme (Windows, vs 4.1.3), if I call (test-serialize), I see the
>>>> expected result:
>>>>
>>>> test-serialize: Saved a: Eddie Sullivan
>>>>
>>>> On the other hand, if I call (go), I see the following error:
>>>>
>>>> Servlet (@ /servlets/standalone.ss) exception:
>>>> test-struct-a: expects args of type <struct:test-struct>; given 
>>>> instance of
>>>> a different <struct:test-struct>
>>>>
>>>> Any tips?
>>>> Thanks.
>>>> -Eddie Sullivan
>>>>
>>>>
>>>>
>>>> _________________________________________________
>>>>  For list-related administrative tasks:
>>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>
>>>
>>>
>>> --
>>> Jay McCarthy <jay at cs.byu.edu>
>>> Assistant Professor / Brigham Young University
>>> http://jay.teammccarthy.org
>>>
>>> "The glory of God is Intelligence" - D&C 93
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>>>
>>
>
>
>
> -- 
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://jay.teammccarthy.org
>
> "The glory of God is Intelligence" - D&C 93
> 



Posted on the users mailing list.