Hi Zoltan, On Tue, Mar 12, 2013 at 9:56 AM, Zoltan Giber <zgi...@gmail.com> wrote: > I'm new to sqlalchemy, writing my first app using it. I stumbled upon a weird > thing; my user object has a pyckletype > representing a python dict, which i can't find a way to update. I assumed, > that a change in the pickled object will > somehow trigger "dirty" and my new data should be there, but it is not. My > goal would be to create an user, and a > notebook for the user, then add the notebook's ID to the > user.views['lastopened'] > > Looking at the code it will be clear i hope (i'm adding some comments here): > > newuser = User(email,name,password) > # creating the new user > newuser.notebooks.append(Notebook("My Notes")) # > the child notebook > newuser.views = {} > session.add(newuser) > session.commit() # couldn't find other way to get the > notebook id, but to make a commit. is there a > better way? > > user = session.query(User).filter_by(email=email).one() # > I'm not sure if a new query is needed here, > this is eliminating uncertainty > defaultnb = user.notebooks[0] > user.views['lastview'] = defaultnb.id > session.commit() > session.close() > > the problem is, that the user.view['lastview'] stays an empty {} ... if i > update it upon creation, it works, but then the > notebook.id is not known to me.
I've not done this myself, but I was curious so I looked in the sqlalchemy docs for PickleType [0]. I found a note that sounds applicable: "To allow ORM change events to propagate for elements associated with PickleType, see Mutation Tracking [1]". I hope this is helpful. Thanks, Matthew [0] http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.PickleType [1] http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/mutable.html -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.