On Wed, 17 Jun 2009 07:14:18 -0700 (PDT), "allen.fowler" <allen.fow...@yahoo.com> wrote: >> 3) Can this relation's objects be made "read-only"? That is: >> "u.room = new_room" would work, but this would not: "u.room.name = >> 'kitchen'" >> > > To clarify the question: > > Can this objects seen via this relation be made "read-only"? That is: > > u.room = a_room > u.room = a_new_room > ...would work fine. > > And this would work, too: > r = session.query(u.room).one() > r.name = "kitchen" > > But, this would not: > u.room.name = 'kitchen' >
This is not possible AFAIK. The reason is that SQLAlchemy ensures that (in your example above) u.room and r would be a reference to the same object, due to the identity map feature. As one might guess, the object can't be immutable in one case and mutable in another, as it doesn't know/care where you obtained the reference from. -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---