2005-04-06 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDBCallback.py: improved error reporting when there is an error in a callback function. Added unittest for exception in callback function. svn: r4305
This commit is contained in:
		@@ -1,3 +1,7 @@
 | 
			
		||||
2005-04-06  Richard Taylor <rjt-gramps@thegrindstone.me.uk>
 | 
			
		||||
	* src/GrampsDBCallback.py: improved error reporting when there is an error in 
 | 
			
		||||
	a callback function. Added unittest for exception in callback function.
 | 
			
		||||
 | 
			
		||||
2005-04-06  Martin Hawlisch  <Martin.Hawlisch@gmx.de>
 | 
			
		||||
	* src/gramps_main.py (post_load): Emit "database-changed" signal instead of
 | 
			
		||||
	calling change_db().
 | 
			
		||||
@@ -11,7 +15,7 @@
 | 
			
		||||
	* src/SourceView.py (__init__): dont call change_cb because on initialisation
 | 
			
		||||
	there is no real database and this will be done by the signal.
 | 
			
		||||
 | 
			
		||||
2005-04-04  Richard Taylor <rjt-gramps@thegrindstone.me.uk>
 | 
			
		||||
2005-04-06  Richard Taylor <rjt-gramps@thegrindstone.me.uk>
 | 
			
		||||
	* src/plugins/ScratchPad.py: made clear buttons sensitive to contents of 
 | 
			
		||||
	list and current selection. Added support for PERSON_LINK dnd.
 | 
			
		||||
	* src/DdTargets.py: added PERSON_LINK target and simplified generation of
 | 
			
		||||
 
 | 
			
		||||
@@ -35,8 +35,9 @@
 | 
			
		||||
    to communicate events to any callback methods in either the database code
 | 
			
		||||
    or the UI code.
 | 
			
		||||
"""
 | 
			
		||||
import types
 | 
			
		||||
import sys
 | 
			
		||||
import types
 | 
			
		||||
import traceback
 | 
			
		||||
 | 
			
		||||
log = sys.stderr.write
 | 
			
		||||
 | 
			
		||||
@@ -364,7 +365,10 @@ class GrampsDBCallback(object):
 | 
			
		||||
                    else:
 | 
			
		||||
                        self._log("Warning: badly formed entry in callback map.\n")
 | 
			
		||||
                except:
 | 
			
		||||
                    self._log("Warning: exception occured in callback function.\n")
 | 
			
		||||
                    log("%s: %s" % (self.__class__.__name__,
 | 
			
		||||
                                    "Warning: exception occured in callback function.\n"))
 | 
			
		||||
                    log("%s: %s" % (self.__class__.__name__,
 | 
			
		||||
                                    "".join(traceback.format_exception(*sys.exc_info()))))
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # instance signals control methods
 | 
			
		||||
@@ -434,6 +438,40 @@ if __name__ == "__main__":
 | 
			
		||||
            assert len(rl) == 1, "No signal emitted"
 | 
			
		||||
            assert rl[0] == 1, "Wrong argument recieved"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        def test_exception_catch(self):
 | 
			
		||||
 | 
			
		||||
            class TestSignals(GrampsDBCallback):
 | 
			
		||||
 | 
			
		||||
                __signals__ = {
 | 
			
		||||
                          'test-signal' : (int,)
 | 
			
		||||
                         }
 | 
			
		||||
 | 
			
		||||
            rl = []
 | 
			
		||||
            def fn(i,r=rl):
 | 
			
		||||
                rl.append(i)
 | 
			
		||||
 | 
			
		||||
            def borked(i):
 | 
			
		||||
                rubish.append(i)
 | 
			
		||||
 | 
			
		||||
            t = TestSignals()
 | 
			
		||||
 | 
			
		||||
            def null(s):
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            global log
 | 
			
		||||
            _log = log
 | 
			
		||||
            log = null
 | 
			
		||||
            
 | 
			
		||||
            t.connect('test-signal',borked)
 | 
			
		||||
            t.connect('test-signal',fn)
 | 
			
		||||
            t.emit('test-signal',(1,))
 | 
			
		||||
            log = _log
 | 
			
		||||
            
 | 
			
		||||
            assert len(rl) == 1, "No signal emitted"
 | 
			
		||||
            assert rl[0] == 1, "Wrong argument recieved"
 | 
			
		||||
 | 
			
		||||
        def test_disconnect(self):
 | 
			
		||||
 | 
			
		||||
            class TestSignals(GrampsDBCallback):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user