if you want to do this "manually", just reassign to the attribute which will
trigger it:
myobject.mypickle = {<dictionary>}
the "mutation" thing is only if you want in-place tracking, that is:
myobject.mypickle['newvalue'] = 'something'
On Mar 12, 2013, at 11:15 AM, Zoltan Giber <[email protected]> wrote:
> Thanks Matthew,
>
> I see that this would be a way, but I'm not very experienced, and
> introducing a new custom type feels like an overkill. I only have three
> pickletype in my whole app, and i don't mind to set "dirty" manually when I
> update them. I don't want to query against their values either.
>
> I was hoping that the mutable=True flag which is True by default according
> the documentation is exactly what i need, but no luck so far..
>
> On Tuesday, March 12, 2013 3:39:10 PM UTC+1, Matthew Desmarais wrote:
> Hi Zoltan,
>
> On Tue, Mar 12, 2013 at 9:56 AM, Zoltan Giber <[email protected]> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.