Re: [Modeling-users] Declaring and using a nested EditingContext
Status: Abandoned
Brought to you by:
sbigaret
From: <pms...@so...> - 2006-07-31 18:18:47
|
Hi again, Thanks a lot! I am sorry for this late feedback, but I have been on holiday :-) I will look into it as soon as I get the time and get back to you at the earliest convenience. Best, Paul Sébastien Bigaret wrote: > 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-sessioning-ec.html > > Just after 0.9 I posted a first patch partially correcting the problem, see the post here: > http://thread.gmane.org/gmane.comp.python.modeling/374/focus=374 > > I'll have some time next week-end to test it in your configuration; if you find some time in the meantime to test it I'll be glad to read your experience :) > > Thanks again for the report, and hopefully the patch will be tested enough to be integrated into the framework soon. > > Cheers, > > -- Sébastien. > > > pms...@so... a écrit : >> Please ignore the previous reply, it was only partly completed; I had a >> little keyboard shortcut accident :-) >> >> Hi Sébastien, >> >> The test you mention run fine here, but still I get no changes in the >> child in the following example, maybe I am doing something weird here. >> Thanks a lot for looking into this :-) >> >> Cheers, >> Paul >> >> >> EXAMPLE >> ======= >> >> pymodel_parentchild.py >> ---------------------------------------------------------------------------- >> from Modeling.PyModel import * >> >> Association.defaults['delete'] = ['nullify', 'nullify'] >> Entity.defaults['properties'] = [] >> >> model = Model('parentchild', version='0.1') >> model.associations = [] >> model.entities = [ >> >> Entity('Person', >> properties = [ >> APrimaryKey('uid', >> isClassProperty=0, >> isRequired=1, doc='PK'), >> AString('first_name', width=60), >> AString('last_name', width=60), >> ], >> ), >> >> ] >> ---------------------------------------------------------------------------- >> >> >> Person.py >> ---------------------------------------------------------------------------- >> from Modeling import dynamic >> __metaclass__ = dynamic.CustomObjectMeta >> >> class Person: >> entityName = 'Person' >> mdl_define_properties = 1 >> ---------------------------------------------------------------------------- >> >> >> >> test_parentchild.py >> ---------------------------------------------------------------------------- >> from parentchild.Person import Person >> from Modeling.EditingContext import EditingContext as EC >> >> parent_ec = EC() >> child_ec = EC(parent_ec) >> >> def populate(ec): >> ec.insert(Person(first_name='Anna', last_name='Anderson')) >> >> def result(): >> global parent_ec, child_ec >> >> print "PARENT:", >> for p in parent_ec.fetch('Person'): print p.first_name, >> p.last_name, >> print >> print "CHILD :", >> for p in child_ec.fetch('Person'): print p.first_name, p.last_name, >> print >> print >> >> print "POPULATING AND SAVING CHANGES" >> populate(parent_ec) >> #parent_ec.processRecentChanges() >> parent_ec.saveChanges() >> >> result() >> >> print "CHANGING 'Anna' --> 'anna' in parent AND SAVING CHANGES" >> anna = parent_ec.fetch('Person', 'first_name=="Anna"')[0] >> anna.first_name = 'anna' >> #parent_ec.processRecentChanges() >> parent_ec.saveChanges() >> >> result() >> ---------------------------------------------------------------------------- >> >> >> OUTPUT FROM TEST >> ------------------------------------------------------------ >> POPULATING AND SAVING CHANGES >> PARENT: Anna Anderson >> CHILD : Anna Anderson >> >> CHANGING 'Anna' --> 'anna' in parent AND SAVING CHANGES >> PARENT: anna Anderson >> CHILD : Anna Anderson >> ------------------------------------------------------------ >> >> >> >> >> Sébastien 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 changes >>>> 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 then >>>> do a fetch on that object in the child, the change is not shown in the >>>> object held by the child EC. >>> Your understanding is correct, and the changes should appear in the child 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ébastien. >>> >>> >>> PS: Oh, BTW, this is tested in tests/test_EditingContext_ParentChildpy, method test_03_fetchedAndModifiedObjectsInParent() >>> >>> pms...@so... a écrit : >>>> Hi all, >>>> >>>> I am reading chapter "5.2 Declaring and using a nested EditingContext" >>>> 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) >>>> that: >>>> >>>> 1. Inserting an object in the parent EC will show up in a fetch in the >>>> child EC. >>>> >>>> 2. Deleting an object in the parent EC deletes it from the result set in >>>> 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 changes >>>> 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 then >>>> do a fetch on that object in the child, the change is not shown in the >>>> 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 >>>> framework :-) >>>> >>>> Cheers >>>> Paul >>>> >>>> Using Tomcat but need to do more? Need to support web services, security? >>>> 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 Geronimo >>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>> _______________________________________________ >>>> Modeling-users mailing list >>>> Mod...@li... >>>> https://lists.sourceforge.net/lists/listinfo/modeling-users >>>> >>>> >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> 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 Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Modeling-users mailing list >> Mod...@li... >> https://lists.sourceforge.net/lists/listinfo/modeling-users >> >> > |