Re: [Modeling-users] Lazy Relation Initialisation
Status: Abandoned
Brought to you by:
sbigaret
|
From: Sebastien B. <sbi...@us...> - 2003-06-19 12:33:49
|
Okay, found it, apply this patch:
------------------------------------------------------------------------
diff -u -r1.13 FaultHandler.py
--- FaultHandler.py 14 Mar 2003 11:40:08 -0000 1.13
+++ FaultHandler.py 19 Jun 2003 12:20:39 -0000
@@ -452,7 +452,8 @@
if sys.version_info >=3D (2, 2): # python v2.2 and higher **UNTESTED**
def __getattr__(self, name):
if name in self.__sequenceTypeMethods:
- self.completeInitializationOfObject(self.__object())
+ if not self.__list:
+ self.completeInitializationOfObject(self.__object())
#trace(self.__object().storedValueForKey(self._relationshipName))
=20=20=20=20=20=20=20=20=20
return getattr(self.__object().storedValueForKey(self._relationshi=
pName), name)
------------------------------------------------------------------------
Thanks for reporting. I still need to check why this was not detected by
the unittests, then I'll put in this in CVS and integrate the fix in the
next release.
Detailed explanation: __iter__ did trigger the fault as expected, and
further __getitem__ also did without noticing that the fault has
already been fired.
-- S=E9bastien.
> Sebastien Bigaret <sbi...@us...> wrote:
>=20
> > Yannick Gingras <yan...@sa...> wrote:
> > > Hi,=20
> > > As I understand (looking at my bandwidth monitor), to-many relations
> > > are lazily retrieved.
> > >=20
> > > ex:=20
> > > myBooks =3D meAsAnAuthor.getBooks() # does not fetch anything=20
> > > for book in myBooks: # fetch a record from the DB each loop
> > > print book.getTitle()
> > >=20
> > > Is there a way to have to fetch the complete meAsAnAuthor with all
> > > it's books once to avoid the connection latency of a fetch for each
> > > book ?
> >=20
> > Could you be more specific? For example, by setting
> > MDL_ENABLE_DATABASE_LOGGING and reporting the fetch you see for each
> > loop? The framework normally fetches all the books when the array is
> > first accessed, and if you find an exception to this rule this is
> > definitely a bug. Here, accessing the array is first done when
> > iterating on it in the for statement.
> [...]
>=20
> Oh well, you're right, the framework misbehaves with py2.2 (my initial
> check was against py2.1)
>=20
> I have submitted bug item #757181 and will have a look at it.
>=20
> -- S=E9bastien.
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Modeling-users mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modeling-users
|