Re: [Modeling-users] Declaring and using a nested EditingContext
Status: Abandoned
Brought to you by:
sbigaret
From:
<sbi...@us...> - 2006-07-12 12:34:06
|
Hi Paul & all, Thanks for the detailed report. Now I can see the problem. It is, in fact, not related to parent/child EC= in particular, but to a more general problem, as described at: http://modeling.sourceforge.net/UserGuide/framework-integration-sessionin= g-ec.html Just after 0.9 I posted a first patch partially correcting the problem, s= ee the post here: http://thread.gmane.org/gmane.comp.python.modeling/374/focus=3D374 I'll have some time next week-end to test it in your configuration; if yo= u find some time in the meantime to test it I'll be glad to read your exp= erience :) =20 Thanks again for the report, and hopefully the patch will be tested enoug= h to be integrated into the framework soon. Cheers, -- S=E9bastien. pms...@so... a =E9crit : > Please ignore the previous reply, it was only partly completed; I had a= =20 > little keyboard shortcut accident :-) >=20 > Hi S=E9bastien, >=20 > The test you mention run fine here, but still I get no changes in the=20 > child in the following example, maybe I am doing something weird here.=20 > Thanks a lot for looking into this :-) >=20 > Cheers, > Paul >=20 >=20 > EXAMPLE > =3D=3D=3D=3D=3D=3D=3D >=20 > pymodel_parentchild.py > -----------------------------------------------------------------------= ----- > from Modeling.PyModel import * >=20 > Association.defaults['delete'] =3D ['nullify', 'nullify'] > Entity.defaults['properties'] =3D [] >=20 > model =3D Model('parentchild', version=3D'0.1') > model.associations =3D [] > model.entities =3D [ >=20 > Entity('Person', > properties =3D [ > APrimaryKey('uid', > isClassProperty=3D0, > isRequired=3D1, doc=3D'PK'), > AString('first_name', width=3D60), > AString('last_name', width=3D60), > ], > ), >=20 > ] > -----------------------------------------------------------------------= ----- >=20 >=20 > Person.py > -----------------------------------------------------------------------= ----- > from Modeling import dynamic > __metaclass__ =3D dynamic.CustomObjectMeta >=20 > class Person: > entityName =3D 'Person' > mdl_define_properties =3D 1 > -----------------------------------------------------------------------= ----- >=20 >=20 >=20 > test_parentchild.py > -----------------------------------------------------------------------= ----- > from parentchild.Person import Person > from Modeling.EditingContext import EditingContext as EC >=20 > parent_ec =3D EC() > child_ec =3D EC(parent_ec) >=20 > def populate(ec): > ec.insert(Person(first_name=3D'Anna', last_name=3D'Anderson')) >=20 > def result(): > global parent_ec, child_ec >=20 > print "PARENT:", > for p in parent_ec.fetch('Person'): print p.first_name,=20 > p.last_name, > print > print "CHILD :", > for p in child_ec.fetch('Person'): print p.first_name, p.last_= name, > print > print >=20 > print "POPULATING AND SAVING CHANGES" > populate(parent_ec) > #parent_ec.processRecentChanges() > parent_ec.saveChanges() >=20 > result() >=20 > print "CHANGING 'Anna' --> 'anna' in parent AND SAVING CHANGES" > anna =3D parent_ec.fetch('Person', 'first_name=3D=3D"Anna"')[0] > anna.first_name =3D 'anna' > #parent_ec.processRecentChanges() > parent_ec.saveChanges() >=20 > result() > -----------------------------------------------------------------------= ----- >=20 >=20 > OUTPUT FROM TEST > ------------------------------------------------------------ > POPULATING AND SAVING CHANGES > PARENT: Anna Anderson > CHILD : Anna Anderson >=20 > CHANGING 'Anna' --> 'anna' in parent AND SAVING CHANGES > PARENT: anna Anderson > CHILD : Anna Anderson > ------------------------------------------------------------ >=20 >=20 >=20 >=20 > S=E9bastien Bigaret wrote: >> Hi Paul & all, >> >> pms...@so... wrote: >> [...] >>> However, I can't quite get what is meant by the sentence: >>> >>> - the states of the objects in the result set will reflect any chan= ges=20 >>> made to them in the parent object store, even the uncommitted ones. >>> >>> From testing, when I change an object held by the parent EC, and the= n=20 >>> do a fetch on that object in the child, the change is not shown in th= e=20 >>> object held by the child EC. >> Your understanding is correct, and the changes should appear in the ch= ild context. If they are not, it is definitely a bug. >> >> Could you please send me your example, where the bug appear? This is = something I did not observe from now on, and I'll be glad to examine and = fix it. >> >> Cheers, >> >> -- S=E9bastien. >> >> >> PS: Oh, BTW, this is tested in tests/test_EditingContext_ParentChildpy= , method test_03_fetchedAndModifiedObjectsInParent() >> >> pms...@so... a =E9crit : >>> Hi all, >>> >>> I am reading chapter "5.2 Declaring and using a nested EditingContext= "=20 >>> in the user guide on the web: >>> >>> http://modeling.sourceforge.net/UserGuide/nested-ec-usage.html >>> >>> I understand and can verify by testing (I am using modeling release 0= .9)=20 >>> that: >>> >>> 1. Inserting an object in the parent EC will show up in a fetch in th= e=20 >>> child EC. >>> >>> 2. Deleting an object in the parent EC deletes it from the result set= in=20 >>> the child EC. >>> >>> However, I can't quite get what is meant by the sentence: >>> >>> - the states of the objects in the result set will reflect any chan= ges=20 >>> made to them in the parent object store, even the uncommitted ones. >>> >>> From testing, when I change an object held by the parent EC, and the= n=20 >>> do a fetch on that object in the child, the change is not shown in th= e=20 >>> object held by the child EC. >>> >>> Can anyone get me on the right track here? >>> >>> And last, but not least, thanks for all the work on this magnificent=20 >>> framework :-) >>> >>> Cheers >>> Paul >>> >>> Using Tomcat but need to do more? Need to support web services, secur= ity? >>> Get stuff done quickly with pre-integrated technology to make your jo= b easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Ger= onimo >>> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&d= at=3D121642 >>> _______________________________________________ >>> Modeling-users mailing list >>> Mod...@li... >>> https://lists.sourceforge.net/lists/listinfo/modeling-users >>> >>> >=20 >=20 > -----------------------------------------------------------------------= -- > Using Tomcat but need to do more? Need to support web services, securit= y? > Get stuff done quickly with pre-integrated technology to make your job = easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geron= imo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > Modeling-users mailing list > Mod...@li... > https://lists.sourceforge.net/lists/listinfo/modeling-users >=20 >=20 |