Changeset 4055

Show
Ignore:
Timestamp:
04/27/2008 11:48:03 AM (2 months ago)
Author:
ed
Message:

Attempt to correct a bug that was reported by Karsten Weinert when navigating through cursors that have new unsaved records with associated new unsaved child records.

I say "attempt" because while it corrects his problem, it may affect other situations, such as that reported by John Fabiani in Trac Issue #1027. Before releasing this to all, could as many of you as possible test this with your parent/child bizobj setups, and let me know of any problems?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/biz/dBizobj.py

    r4046 r4055  
    12641264            raise dException.BusinessRuleViolation, errMsg 
    12651265 
    1266         if self.IsAdding and self.AutoPopulatePK: 
    1267             pk = None 
    1268         else: 
    1269             try: 
    1270                 pk = self.getPK() 
    1271             except dException.NoRecordsException: 
    1272                 # There aren't any records, all children should requery to 0 records. 
    1273                 # We can't set the pk to None, because None has special meaning  
    1274                 # elsewhere (self.__currentCursorKey). 
    1275                 pk = NO_RECORDS_PK 
     1266        newAutopop = (self.IsAdding and self.AutoPopulatePK) 
     1267        try: 
     1268            pk = self.getPK() 
     1269        except dException.NoRecordsException: 
     1270            # There aren't any records, all children should requery to 0 records. 
     1271            # We can't set the pk to None, because None has special meaning  
     1272            # elsewhere (self.__currentCursorKey). 
     1273            pk = NO_RECORDS_PK 
    12761274 
    12771275        for child in self.__children: 
     
    12791277            if child.RequeryWithParent: 
    12801278                child.setCurrentParent(pk, fromChildRequery=True) 
    1281                 if not child.isAnyChanged(): 
     1279                if newAutopop and (child.RowCount == 0): 
     1280                    parentPK = None 
     1281                else: 
     1282                    parentPK = pk 
     1283                if not child.isAnyChanged(parentPK=parentPK): 
    12821284                    child.requery() 
    12831285        self.afterChildRequery()