[PythonCAD] PythonCAD and exception handling in sendMessage() calls

Art Haas ahaas at airmail.net
Mon May 23 17:24:06 CEST 2005


Hi.

More thinking and reading over the last few days has produced no
solution to the potential problem regarding handling exceptions during
sendMessage() calls. The various strategies people have proposed are all
potential areas for development, but for the short term I'm going to
leave that work to someone else.

The thread on the QT mailing list mentioned in an earlier mail has
pushed me to believe that there should not be any sort of rollback or
restoration of a changed value in some entity if one of the
sendMessage() calls fails. Consider the simplfied setThickness() code
I'd posted earlier:

def setThickness(self, t):
	_ot = self.__thickness
	if abs(_ot - t) > 1e-10:
		self.__thickness = t
		self.sendMessage('thickness_changed', _ot)
		self.modified() # calls self.sendMessage('modified')

The object that had the thickness change has no idea what is listening
to the 'thickness_changed' or 'modified' messages, nor should it. Once
the new value is set the entity is at its new state, and reverting it
because some unknown listener had a problem doing who knows what
suggests that the entity has some sort of knowledge about what that
listener does, and that is not how things work in the messaging system,
nor in QT's signal()/slots() implementation for that matter.

I'm still going to investigate ways of ensuring that the all sendMessage()
calls in some block of code get called if an exception is raised during one
of those calls. It may take several releases before any preliminary code
emerges, and whatever code does appear will almost certainly change
several times before a reasonable approach is finalized.

Here's the thread on the QT mailing list once again for those
interested:

http://lists.trolltech.com/qt-interest/2003-03/thread00680-0.html

Art
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list