Changeset 4288

Show
Ignore:
Timestamp:
07/16/2008 01:55:41 PM (1 month ago)
Author:
paul
Message:

Added back a try: block that was removed in [4184] to stuff the
getBlankValue() into self.Value if calling the instance method
raises dException.NoRecordsException?.

This fixes one of my problems with HEAD. I have a bunch of functions
in the UI that are thin wrappers to methods of the bizobj, and
these ui functions will run with the ui update() calls, but I
can't seem to control when update() will happen, and it sometimes
seems to happen when the dialog is hidden, or before the dialog is
ready for display, or after it is already being destroyed or hidden.

I don't want to catch biz.NoRecordsException? in each one of these ui
wrappers; I just want the controls to get the blank value for now,
as it isn't an actual problem (after the dialog is shown, the controls
update themselves with valid values from the bizobj functions).

Also did some minor housekeeping around that section of the code.


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/dDataControlMixinBase.py

    r4184 r4288  
    106106            return 
    107107 
    108         if self.Source and self._srcIsBizobj: 
     108        src = self.Source 
     109        if src and self._srcIsBizobj: 
    109110            # First see if DataField refers to a method of the bizobj: 
    110             method = getattr(self.Source, self.DataField, None) 
     111            method = getattr(src, self.DataField, None) 
    111112            if method is not None: 
    112113                self.Value = method() 
    113114            else: 
    114115                try: 
    115                     self.Value = self.Source.getFieldVal(self.DataField) 
     116                    self.Value = src.getFieldVal(self.DataField) 
    116117                except (TypeError, dException.NoRecordsException): 
    117118                    self.Value = self.getBlankValue() 
    118119        else: 
    119             src = self.Source 
    120120            if self._srcIsInstanceMethod is None and src is not None: 
    121121                if isinstance(src, basestring): 
     
    125125            srcatt = getattr(src, self.DataField) 
    126126            if self._srcIsInstanceMethod: 
    127                 self.Value = srcatt() 
     127                try: 
     128                    self.Value = srcatt() 
     129                except dException.NoRecordsException: 
     130                    ## Couldn't run the method. If it was due to there being no records 
     131                    ## in the bizobj, fill in the blank value. 
     132                    self.Value = self.getBlankValue() 
    128133            else: 
    129134                self.Value = srcatt