Thread: [Modeling-users] CustomObject.snapshot()
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2003-07-17 11:45:41
|
Hi, Working on the ability to fetch raw rows, I incidentally found out that the snapshot method is not behaving the way I thought it was (this case was not tested and left undetermined). The current behaviour is (using the StoreEmployees model & test data): >>> ec=3DEditingContext() >>> circus=3Dec.fetch('Store', 'corporateName =3D=3D "Flying Circus"')[0] >>> circus.getEmployees().isFault() 1 >>> circus.snapshot() {'corporateName': 'Flying Circus', 'employees': None} >>> len(circus.getEmployees()) # clears the fault and fetches the array 3 >>> pprint.pprint(circus.snapshot()) {'corporateName': 'Flying Circus', 'employees': [<Modeling.GlobalID.KeyGlobalID instance at 0x8539884>, <Modeling.GlobalID.KeyGlobalID instance at 0x85271f4>, <Modeling.GlobalID.KeyGlobalID instance at 0x851ccfc>]} As you can see, when the array of 'employees' is faulted (it has not been fetched yet), it appears as None in the snapshot. It seems quite weird to me. I'd highly prefer to return something like this: >>> pprint.pprint(circus.snapshot()) {'corporateName': 'Flying Circus', 'employees': <Modeling.FaultHandler.AccessArrayFaultHandler instance at 0x= 8539034>} I'll probably change this, but I'd like to get your opinion on that, especially I'd like to know how you handle this if you're already using CustomObject.snapshot() in your own projects, and if such a modification could fit your needs. -- S=E9bastien. |
From: Sebastien B. <sbi...@us...> - 2003-07-21 13:01:07
|
Hi, Does nobody uses CustomObject.snapshot()? Is it safe to make the modification suggested in my previous post (included below)? You can either reply to this post, or comment bug item #774989 at https://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D774989&group_= id=3D58935&atid=3D489335 -- S=E9bastien. Note: AccessArrayFaultHandler instances are proxy-like objects handling to-many relationships that are not fetched yet (they are responsible for lazy initialization of to-many rels). I wrote: > Working on the ability to fetch raw rows, I incidentally found out > that the snapshot method is not behaving the way I thought it was > (this case was not tested and left undetermined). >=20 > The current behaviour is (using the StoreEmployees model & test data): >=20 > >>> ec=3DEditingContext() > >>> circus=3Dec.fetch('Store', 'corporateName =3D=3D "Flying Circus"')[0] > >>> circus.getEmployees().isFault() > 1 > >>> circus.snapshot() > {'corporateName': 'Flying Circus', 'employees': None} > >>> len(circus.getEmployees()) # clears the fault and fetches the array > 3 > >>> pprint.pprint(circus.snapshot()) > {'corporateName': 'Flying Circus', > 'employees': [<Modeling.GlobalID.KeyGlobalID instance at 0x8539884>, > <Modeling.GlobalID.KeyGlobalID instance at 0x85271f4>, > <Modeling.GlobalID.KeyGlobalID instance at 0x851ccfc>]} >=20 >=20 > As you can see, when the array of 'employees' is faulted (it has not > been fetched yet), it appears as None in the snapshot. It seems quite > weird to me. I'd highly prefer to return something like this: >=20 >=20 > >>> pprint.pprint(circus.snapshot()) > {'corporateName': 'Flying Circus', > 'employees': <Modeling.FaultHandler.AccessArrayFaultHandler instance at = 0x8539034>} >=20 > I'll probably change this, but I'd like to get your opinion on that, > especially I'd like to know how you handle this if you're already > using CustomObject.snapshot() in your own projects, and if such a > modification could fit your needs. >=20 > -- S=E9bastien. |
From: Yannick G. <yan...@sa...> - 2003-07-21 13:27:33
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On July 21, 2003 09:01 am, Sebastien Bigaret wrote: > Does nobody uses CustomObject.snapshot()? Is it safe to make the > modification suggested in my previous post (included below)? I used to but I prefer the raw fetch. =2D --=20 Yannick Gingras Byte Gardener, Savoir-faire Linux inc. (514) 276-5468 =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/G+oprhy5Fqn/MRARAkoqAJ9+2wrBZbTpGqcAF1stK29+wFQidQCaA/Rr hHeXO9n6fKqSD7/Sct9INhk=3D =3DIy7w =2D----END PGP SIGNATURE----- |
From: Sebastien B. <sbi...@us...> - 2003-07-28 17:29:29
|
Hi, Since this got no further comments in almost two weeks I'll let the change happen in the next release. --> CustomObject.snapshot will return a to-many fault (AccessArrayFaultHandler) instead of None when a key holds a faulted sequence of objects, instead of None. -- S=E9bastien. > Working on the ability to fetch raw rows, I incidentally found out > that the snapshot method is not behaving the way I thought it was > (this case was not tested and left undetermined). >=20 > The current behaviour is (using the StoreEmployees model & test data): >=20 > >>> ec=3DEditingContext() > >>> circus=3Dec.fetch('Store', 'corporateName =3D=3D "Flying Circus"')[0] > >>> circus.getEmployees().isFault() > 1 > >>> circus.snapshot() > {'corporateName': 'Flying Circus', 'employees': None} > >>> len(circus.getEmployees()) # clears the fault and fetches the array > 3 > >>> pprint.pprint(circus.snapshot()) > {'corporateName': 'Flying Circus', > 'employees': [<Modeling.GlobalID.KeyGlobalID instance at 0x8539884>, > <Modeling.GlobalID.KeyGlobalID instance at 0x85271f4>, > <Modeling.GlobalID.KeyGlobalID instance at 0x851ccfc>]} >=20 >=20 > As you can see, when the array of 'employees' is faulted (it has not > been fetched yet), it appears as None in the snapshot. It seems quite > weird to me. I'd highly prefer to return something like this: >=20 >=20 > >>> pprint.pprint(circus.snapshot()) > {'corporateName': 'Flying Circus', > 'employees': <Modeling.FaultHandler.AccessArrayFaultHandler instance at = 0x8539034>} >=20 > I'll probably change this, but I'd like to get your opinion on that, > especially I'd like to know how you handle this if you're already > using CustomObject.snapshot() in your own projects, and if such a > modification could fit your needs. |