[racket] Stateless Webserver

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Aug 16 16:14:55 EDT 2012

On Thu, Aug 16, 2012 at 1:25 PM, J G Cho <gcho at fundingmatters.com> wrote:
> Hello,
> I am going over the Blog Tutorial (
> http://docs.racket-lang.org/continue/index.html ) and trying to run it
> "Stateless".
> I made it to the version where the model is put into a separate module
> model.rkt with small changes:
> (require racket/serialize)
> (serializable-struct  blog (posts) #:mutable)
> (serializable-struct post (title body comments) #:mutable)
> But when I try out model-2.rkt and model-3.rkt, I run into some trouble.
> 1) With model-2.rkt, #:prefab seems to be in conflict with
> serializable-struct. I get the following error msg:
> ;; serializable-struct: cannot use #:property specification for prefab
> structure type in: #:property
> Without #:prefab, however, the model is changed (ie changes are
> visible) but nothing is written to .db file.

You'll have to use (write (serialize a-blog)) and (compose deserialize
read) in the reading and writing functions (initialize-blog! and

> 2) With model-3.rkt, I get a different error msg:
> ;; stuff-url: Cannot stuff (kont
> #<procedure:...abort-resume.rkt:145:3>) into a URL
> ;; because it contains non-serializable pieces.
> ;; Convert (object:connection% ...) to a serializable struct
> How can I overcome these?

You'll have to change the structure of the application so the DB
connection is not in the continuation. You could have a single global
variable, which would work fine for this. You could use a global table
associating serial values, like numbers, to the db. soft-state may
help you with that. I'd recommend the global variable for this


> Regards,
> jGc
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.