Thread: [Modeling-users] CustomObject.globalID() problem
Status: Abandoned
Brought to you by:
sbigaret
From: <no...@ti...> - 2004-10-04 02:19:06
|
Hello all, looking at the code for globalID() in CustomObject I see that a new EC is created on the fly and a globalID for self is looked up in it, question is (and I'm probably too asleep) how does an newly created EC know about a globalID of an object fetched in another EC? I would have thought some sort of call back in the parentObjectStore but I can't see it in the code. Enlight me please :) ciao -- Delio |
From: Sebastien B. <sbi...@us...> - 2004-10-04 15:54:07
|
Hi Delio, no...@ti... wrote: > Hello all, >=20 > looking at the code for globalID() in CustomObject I see that a new EC is= created on the fly and a globalID for self is looked up in it, question is= (and I'm probably too asleep) how does an newly created EC know about > a globalID of an object fetched in another EC? I would have thought some = sort of call back in the parentObjectStore but I can't see it in the code. = Enlight me please :) >=20 > ciao You were probably too asleep ;) CustomObject.globalID() does NOT create any EC, but 1. asks self for its EC, 2. asks that ec for the object's gid And since you're curious, here are some more: the EC stored in the CustomObject is in fact a weakref to the real EC --that's why it is initialized as a void lambda func BTW. That weak reference is initialized = by the EC when the object is registered (either newly inserted or fetched from the db), look at EC.recordObject() if you want to see the code! -- S=E9bastien. PS: oh, BTW, you'll probably also note the double underscore in 'CustomObject.__editingContext'... and the ugly line: anObject._CustomObject__editingContext=3Dweakref.ref(self) =20=20=20=20 within EC.recordObject() =20=20=20=20 This comes from a time when I thought some fields should not be exposed (at least --since this is python:)-- not easily changed from the outsid= e), so I choose to use the private name mangling for some variables. There are some examples of this in the framework alas, I think I'll cha= nge them at some point: I now tend to think that this is not very pythonic, and that a single underscore and good documentation should be sufficient (or, at least, use a private method _setEC() instead of that explicit n= ame mangling stuff in another class, isn't that supposed to be private after all ?-/). |
From: <no...@ti...> - 2004-10-04 16:13:26
|
On 04 Oct 2004 17:53:04 +0200 Sebastien Bigaret <sbi...@us...> wrote: > You were probably too asleep ;) soooo true! just opened the src file and saw it... ^^; thanks, I got a problem here related to a 'just fetched' object that returns none as globalID, considered I couldn't read the code properly I highly doubt it's a bug in Modeling. I'll look into it better, and come up with a proper bug report if that's the case. cheers -- 'yours ZzZzleepy' Delio |
From: Sebastien B. <sbi...@us...> - 2004-10-05 21:42:20
|
no...@ti... wrote: > On 04 Oct 2004 17:53:04 +0200 > Sebastien Bigaret <sbi...@us...> wrote: >=20 > > You were probably too asleep ;) >=20 > soooo true! just opened the src file and saw it... ^^; > thanks, I got a problem here related to a 'just fetched' > object that returns none as globalID, considered I couldn't read > the code properly I highly doubt it's a bug in Modeling. > I'll look into it better, and come up with a proper bug report > if that's the case. Okay; if you observe that a freshly fetched object has None as globalId(), this is definitely a bug, so do not hesitate to report! -- S=E9bastien. > cheers > -- > 'yours ZzZzleepy' Delio |
From: <no...@ti...> - 2004-10-06 05:49:16
|
On 05 Oct 2004 23:42:47 +0200 Sebastien Bigaret <sbi...@us...> wrote: > Okay; if you observe that a freshly fetched object has None as globalId(), > this is definitely a bug, so do not hesitate to report! I have a deadline on friday and don't have time to write a test, it's nasty ( or simply a problem with my code ) since it appears only if another thread is fetching the same object from the same EC while I try to retrieve the GlobalID. Wouldn't worry until I got some real evidence :-) ciao -- Delio |
From: Sebastien B. <sbi...@us...> - 2004-10-08 09:03:53
|
no...@ti... wrote: > On 05 Oct 2004 23:42:47 +0200 > Sebastien Bigaret <sbi...@us...> wrote: >=20 > > Okay; if you observe that a freshly fetched object has None as globalId= (), > > this is definitely a bug, so do not hesitate to report! >=20 > I have a deadline on friday and don't have time to write a test, it's nas= ty > ( or simply a problem with my code ) since it appears only if another thr= ead is > fetching the same object from the same EC while I try to retrieve the Glo= balID. > Wouldn't worry until I got some real evidence :-) Are you, by any chance, concurrently accessing the same EC without locking it? If you do, then maybe you should probably re-read the dedicated section in the User's Guide :) http://modeling.sourceforge.net/UserGuide/framework-integration-MT-consider= ations.html Operations on an EC is not thread-safe by default, and concurrent access w/o locking it first could lead to the behaviour you observe (where an object can be observed w/ a gID=3D=3DNone by a given thread while the fetch procedure is still processed in an other thread). -- S=E9bastien. |
From: <no...@ti...> - 2004-10-08 13:21:00
|
On 08 Oct 2004 11:02:41 +0200 Sebastien Bigaret <sbi...@us...> wrote: > Are you, by any chance, concurrently accessing the same EC without > locking it? If you do, then maybe you should probably re-read the > dedicated section in the User's Guide :) > http://modeling.sourceforge.net/UserGuide/framework-integration-MT-considerations.html I remember that bit right while writing the previous email :) , I think thats where the problem was. thanks -- Delio |