dabo Commit
Revision 4288
Date: 2008-07-16 13:55:41 -0700 (Wed, 16 Jul 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4288

Changed:
U   trunk/dabo/ui/dDataControlMixinBase.py

Log:
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.

 


Diff:
Modified: trunk/dabo/ui/dDataControlMixinBase.py
===================================================================
--- trunk/dabo/ui/dDataControlMixinBase.py      2008-07-16 19:02:01 UTC (rev 
4287)
+++ trunk/dabo/ui/dDataControlMixinBase.py      2008-07-16 20:55:41 UTC (rev 
4288)
@@ -105,18 +105,18 @@
                if self._DesignerMode:
                        return
 
-               if self.Source and self._srcIsBizobj:
+               src = self.Source
+               if src and self._srcIsBizobj:
                        # First see if DataField refers to a method of the 
bizobj:
-                       method = getattr(self.Source, self.DataField, None)
+                       method = getattr(src, self.DataField, None)
                        if method is not None:
                                self.Value = method()
                        else:
                                try:
-                                       self.Value = 
self.Source.getFieldVal(self.DataField)
+                                       self.Value = 
src.getFieldVal(self.DataField)
                                except (TypeError, 
dException.NoRecordsException):
                                        self.Value = self.getBlankValue()
                else:
-                       src = self.Source
                        if self._srcIsInstanceMethod is None and src is not 
None:
                                if isinstance(src, basestring):
                                        self._srcIsInstanceMethod = False
@@ -124,7 +124,12 @@
                                        self._srcIsInstanceMethod = 
callable(getattr(src, self.DataField))
                        srcatt = getattr(src, self.DataField)
                        if self._srcIsInstanceMethod:
-                               self.Value = srcatt()
+                               try:
+                                       self.Value = srcatt()
+                               except dException.NoRecordsException:
+                                       ## Couldn't run the method. If it was 
due to there being no records
+                                       ## in the bizobj, fill in the blank 
value.
+                                       self.Value = self.getBlankValue()
                        else:
                                self.Value = srcatt
 




_______________________________________________
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