dabo Commit
Revision 5526
Date: 2009-11-14 12:39:40 -0800 (Sat, 14 Nov 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5526

Changed:
U   trunk/dabo/biz/dBizobj.py

Log:
This is a second attempt at fixing the issues with RequeryOnLoad, as noted by 
Jacek Ka?\197?\130ucki.


Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2009-11-14 18:37:01 UTC (rev 5525)
+++ trunk/dabo/biz/dBizobj.py   2009-11-14 20:39:40 UTC (rev 5526)
@@ -36,13 +36,16 @@
                # Dictionary holding any default values to apply when a new 
record is created. This is
                # now the DefaultValues property (used to be self.defaultValues 
attribute)
                self._defaultValues = {}
+
                # PKs of rows to be filtered out when filtering Virtual fields
                self.__filterPKVirtual = []
                
                self._beforeInit()
-
-               # This must be set before the call to setConnection(). Thanks 
to Jacek Kałucki for 
-               # noticing this problem.
+               # This starts as a list that will hold cursors created in the 
initial process
+               # if RequeryOnLoad is True. This is necessary because not all 
of the required
+               # properties will have been set at this point. 
+               # It will be set to None in the _afterInit() code, to indicate 
that it is no longer relevant.
+               self.__cursorsToRequery = []
                self._requeryOnLoad = self._extractKey((properties, kwargs), 
"RequeryOnLoad", False)
                self.setConnection(conn)
                # We need to make sure the cursor is created *before* the call 
to
@@ -88,7 +91,6 @@
                self.dbapiCursorClass = None
                self._childCacheInterval = None
 
-
                ##########################################
                ### referential integrity stuff ####
                ##########################################
@@ -106,6 +108,14 @@
                self.beforeInit()
 
 
+       def _afterInit(self):
+               super(dBizobj, self)._afterInit()
+               for crs in self.__cursorsToRequery:
+                       self._syncCursorProps(crs)
+                       crs.requery()
+               self.__cursorsToRequery = None
+
+
        def setConnection(self, conn):
                """Normally connections are established before bizobj creation, 
but
                for those cases where connections are created later, use this 
method to
@@ -181,8 +191,13 @@
                crs._bizobj = self
                self._syncCursorProps(crs)
                if self.RequeryOnLoad:
-                       crs.requery()
-                       self.first()
+                       if self.__cursorsToRequery is None:
+                               # We've already passed the bizobj init process
+                               crs.requery()
+                               self.first()
+                       else:
+                               # Still in the init, so add it to the list
+                               self.__cursorsToRequery.append(crs)
                self.afterCreateCursor(crs)
                return crs
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to