DM object in session breaks ("no marshal_dump is defined for class Proc") if model has associations

13 views
Skip to first unread message

curtisabbott

unread,
Dec 4, 2008, 9:08:04 PM12/4/08
to merb
I'm using
merb_gems_version = "1.0.3"
dm_gems_version = "0.9.7"

If my model uses associations (either has 1 or has n) and I try to
store an instance in session[], I get the marshal_dump error.
Googling for that error message leads to a post by Ezra from April
2006 (!) responding to a guy with the same problem in Rails, Ezra says

You cannot marshal objects that have procs or lambdas in them. Its a
current limitation of the ruby interpreter. What exactly are you
storing in the session? Whole objects? Or just id's? SHow me what
you
are storing in the session and I can help you figure it out.

Ok, I guess it's still a limitation. I haven't read enough Datamapper
code to understand why it puts Procs in the object when associations
are declared but this seems like a fairly big deal to me. (BTW,
session storage works fine until associations are declared, then
breaks even if no associations are actually present for the object.)

Why a big deal? I need to store partly built objects somewhere when
they're complex enough to require several pages to get defined. I
really don't want to save partly built objects to the repository so I
can store only their id in the session. It causes lots of cruft, it's
hairy, etc.

Are others seeing this? Looks like others are seeing this issue in
memcache & some other places. What are people doing about it?
Pointers to workarounds would be most welcome!

curtisabbott

unread,
Dec 5, 2008, 3:15:41 PM12/5/08
to merb
Hmmmm, no ideas, eh? Ok, I've filed a ticket on lighthouseapp and
will abandon Datamapper for now.

Michael Klishin

unread,
Dec 5, 2008, 3:37:52 PM12/5/08
to me...@googlegroups.com

On 05.12.2008, at 22:15, curtisabbott wrote:

> Hmmmm, no ideas, eh?


Are you trying to put the object itself (not it's class name and/or
id) to the session?
If so, I highly recommend not doing so, one day your application will
fail to unmarshal existing object
until all sessions are cleared.

This has been discussed many times before. Putting objects in the
session is *bad*, and the fact that Merb and DM do not
really allow this atm is a good thing, and not a bug.

MK

Reply all
Reply to author
Forward
0 new messages