Re: [Modeling-users] CustomObject.snapshot()
Status: Abandoned
Brought to you by:
sbigaret
|
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.
|