sqlobject does not detect the object modification.
My workaround is to call .set everytime you modify the pickled object.
see below
Christopher DeMarco a écrit :
> I can use PickleCol in "brute force" mode, but not in "native dict
> mode".  Here's my toy program:
>
>
> # # ## ### ##### ######## ############# #####################
>
> from sqlobject import SQLObject, PickleCol, StringCol
> import sys
>
> __connection__ = "sqlite:///home/cmd/tg/test.sqlite?debug=1"
>
> class Test(SQLObject):
>     test = PickleCol(default=None)
>
> Test.createTable(ifNotExists=True)
> t = Test()
> t.test = {'foo': 'bar'}  # This is fine, the sqlite row is filled
> t = Test.get(1)          
> print t.test             # Also fine
> t.test['baz'] = 'mumble'
>   
here you could write after the object modification:
t.set(test=t.test)
this does force the rewrite of the object.
> print t.test             # This is fine
>                          # But the row isn't updated in sqlite!
>
> # If at first you don't succeed, force it:
> import copy
> scratch = copy.copy(t.test)
> scratch['baz'] = 'mumble'
> t.test = scratch         # now I can see the row in sqlite.
>
>
> What am I missing?
>
>
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to