Changeset 325 for trunk/ui

Show
Ignore:
Timestamp:
06/12/04 11:27:04 (5 years ago)
Author:
paul
Message:

Change default params value to the empty tuple in dBizobj. Since different
backends expect different types for the params arg, modify dCursorMixin.execute
to not send the params arg at all if it is None or otherwise empty. Tested with
MySQL and Firebird: Ok.

Modified dbFirebird's getCursor() to do the required mixing-in and to return
a full Dabo cursor instance. dbFirebird now gets past all the initial errors
in my wiz-generated test app. Next up: there is MySQL-specific code in my
dPageDataNav code - dbFirebird is currently choking on the LIMIT clause.

Modified dProgressDialog to properly react to exceptions that happen in the
passed function. It used to be that if an exception happened in the requery()
code, the dProgressDialog wouldn't handle it and therefore the worker thread
would never return control back to the main thread. Now, control is returned
and the main thread tries to show useful information about the exception. It
is a start at least.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ui/uiwx/classes/dProgressDialog.py

    r232 r325  
    3030from threading import * 
    3131import wx 
    32 import time 
     32import dMessageBox 
    3333 
    3434ID_CANCEL = wx.NewId() 
    3535EVT_RESULT_ID = wx.NewId() 
     36EVT_EXCEPTION_ID = wx.NewId() 
    3637 
    3738def EVT_RESULT(win, func): 
    3839    win.Connect(-1, -1, EVT_RESULT_ID, func) 
     40 
     41def EVT_EXCEPTION(win, func): 
     42    win.Connect(-1, -1, EVT_EXCEPTION_ID, func) 
    3943 
    4044class ResultEvent(wx.PyEvent): 
     
    4549        wx.PyEvent.__init__(self) 
    4650        self.SetEventType(EVT_RESULT_ID) 
     51        self.response = response 
     52 
     53class ExceptionEvent(wx.PyEvent): 
     54    """ Simple event to carry arbitrary result data. 
     55    """ 
     56 
     57    def __init__(self, response): 
     58        wx.PyEvent.__init__(self) 
     59        self.SetEventType(EVT_EXCEPTION_ID) 
    4760        self.response = response 
    4861 
     
    6376 
    6477    def run(self): 
    65         response = self._func() 
    66         # Done, send notify: 
    67         wx.PostEvent(self._notify_window,ResultEvent(response)) 
     78        try: 
     79            response = self._func() 
     80            # Done, send notify: 
     81            wx.PostEvent(self._notify_window,ResultEvent(response)) 
     82        except Exception, e: 
     83            wx.PostEvent(self._notify_window,ExceptionEvent(e)) 
    6884 
    6985# GUI Frame class that spins off the worker thread 
     
    8197        # Set up event handler for any worker thread results 
    8298        EVT_RESULT(self, self.OnResult) 
     99        EVT_EXCEPTION(self, self.OnException) 
    83100 
    84101        # And indicate we don't have a worker thread yet 
     
    98115        self.Hide() 
    99116 
     117    def OnException(self, event): 
     118        dMessageBox.stop("Error encountered:\n\n%s" % str(event.response)) 
     119        self.Hide() 
     120     
    100121    def OnClose(self, event): 
    101122        # Don't let the window close.