On Sat, Apr 24, 2010 at 02:52:40PM +0530, rohit wrote:
> 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.

I do not see that in your code.

> 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

You use a lot of nested non-persistent mutable objects (i.e. dicts).
Please be aware that if you modify any of them, you need to find the
containing *persistent* object and set its _p_changed to True.

Your life would be much easier if you used PersistentDict and
PersistentList instead of the builtin classes.

> 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.

Marius Gedminas
-- 
No proper program contains an indication which as an operator-applied
occurrence identifies an operator-defining occurrence which as an
indication-applied occurrence identifies an indication-defining occurrence
different from the one identified by the given indication as an
indication-applied occurrence.
                -- ALGOL 68 Report

Attachment: signature.asc
Description: Digital signature

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to