Sorry I missed this thread up until now.  I wasn't paying close
attention!  Lets see if I can offer some insight.

> The general idea of what I'd like to do is create the object from
> the Elixir model, modify some of its attributes, pickle it in the
> HTTP session. In a subsequent HTTP request, deserialize it, modify
> more of the attributes and then save it to the DB. There are other
> ways to do this in a more brute force way, but I'd like to use the
> tools that sqlalchemy provides.

I think that the problem may very well be Elixir-related, as the
mapper and table are attached to the class once they are set up by
Elixir. This could explain why pickle is attempting to pickle the
mapper and the table.  If this is the case, we might be able to get
around this by putting a custom `__getstate__` and `__setstate__` on
the `Entity` base class, but this seems kinda crazy to me.

To be entirely honest with you, I think you'd be better off not
attempting to pickle objects into your session, which could get out
of hand relatively quickly.  It sounds like you are building up
an object across multiple HTTP requests, and I'd suggest that you
consider not creating the object and persisting it to the database
until all of that data is available.

In cases like these, I tend to use AJAX, and push the state to the
client side, where it won't cause as many scaling problems for me
later.  Alternatively, if you're really bound to a session-backed
method for doing this, you could store a more simple representation
of state (like a dictionary) in the session, which is pretty simply,
especially when you can construct your model object like this on the
last request:

     state = session.get('object_state')
     instance = MyEntity(**state)
     instance.flush()

Good luck, and if you have any further questions, don't hesitate
to ask over on the Elixir mailing list.  I'll do my best to answer
followups over there!

--
Jonathan LaCour
http://cleverdevil.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to