On Thu, Aug 16, 2012 at 1:25 PM, J G Cho <[email protected]> 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 save-blog!) > > 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 application. Jay > > Regards, > > jGc > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93 ____________________ Racket Users list: http://lists.racket-lang.org/users

