[ZODB-Dev] Change in a mutable object(list) not being recognized by ZODB
rohit
76.rohit at gmail.com
Sat Apr 24 05:22:40 EDT 2010
I have a situation wherein a change made to an attribute(a list) of a ZODB
obj, is not being recognized.I have set the _p_changed = 1.
But still the ZODB doesnt recognize the change.On debugging i realised that
the obj has the change and then i do a transaction.commit() and close the
database.But on reaccessing the database i realise that the change hasnt
been registered.
Could someone please help me out on this one
The code is ::::
s=open_zodb()
root=s[0]
if not root.has_key("Clubs"):
root["Clubs"] = {}
ClubRoot=root["Clubs"]
if not root.has_key("Managers"):
root["Managers"] = {}
ManagerRoot=root["Managers"]
if not root.has_key("Players"):
root["Players"]={}
PlayerRoot=root["Players"]
if not root.has_key("Count"):
root["Count"] = {}
CountRoot=root["Count"]
club=findclubsbyname(ClubRoot, 'MI')
print club.Players
list=addplayers(PlayerRoot, CountRoot, "b", 99, 100)
PlayerRoot=list[1]
CountRoot=list[0]
player=findplayerbyname(PlayerRoot, "b")
player.Club=club
playerset=[]
playerset.append(player)
playerset.append(player)
#club.Players.append(player)
club.makeclubplayerassociation(playerset)
ClubRoot[club.ClubID]=club
root['Players']=PlayerRoot
root['Clubs']=ClubRoot
transaction.commit()
close_zodb(s)
//open_zodb() is a function which just opens connection to the databse.
findclubsbyname returns a club object .
addplayers is a function which adds a player and returns PlayerRoot and
CountRoot
findplayerbyname returns a player object
every club object has an attribte Players which is a list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zodb-dev/attachments/20100424/c40de697/attachment.html
More information about the ZODB-Dev
mailing list