On 5/27/07, Anil <[EMAIL PROTECTED]> wrote:
> user_mapper = assign_mapper(ctx, User, user_table,
> properties = {
> 'alerts': relation(Alert,
> cascade="all, delete-orphan")
> })
> alert_mapper = assign_mapper(ctx, Alert, alert_table)
>
>
> user = session["user"]
> alert = model.Alert(form_result["name"])
> user.alerts.append(alert)
> user.save_or_update()
> user.flush()
>
>
> I save a User SA object in session["user"] in another page. Then, in
> this page, I try to add Alert objects to the user object. I get this
> exception.
>
> <class 'sqlalchemy.exceptions.InvalidRequestError'>: Object
> '<entic.models.Alert object at 0xcc2970>' is already attached to
> session '13378672' (this is '12302224')
>
> Can someone give me pointers on how I can resolve this?
>
> Plus, are there any best practices for passing around SA mapped
> objects in beaker sessions?
I would say *don't* ;)
I wouldn't expect a SA object to be serializable. It just doesn't
make sense to me. I don't even want to think about complications with
the database and ACID, nor do I want to consider the scalability
concerns (the SA object should be tied to a particular SA session,
right?).
It just boggles my mind. I would say put some other non-SA-specific
object in the session, and then redo the SA stuff once you get it out
of the session.
(Of course, I could be wrong, but I don't think so.)
Happy Hacking!
-jj
--
http://jjinux.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---