sugarbot's aim is to provide testing and automation facilities for the OLPC Project's Sugar GUI. The project must first identify and evaluate possible implementation options, and then implement the best choice. Although it has a Sugar focus, sugarbot should be easily extensible to other Python-based GUI's.

Monday, May 19, 2008

Which came first, the snake or the egg?

I've run into quite an interesting little debacle.  The only function that I can guarantee gets called when an activity is loaded is myActivity.__init__().  Unfortunately, if I create an instance of a different activity, its anotherActivity.__init__ function is called.  For whatever reason, Sugar wants to attach a few things to myActivity object.  However, myActivity.__init__ has not finished execution, so a TypeError exception is raise.

Maybe spawning a separate thread would solve the issue?

Update: Solved the issue by using runtime inheritance, by some nifty manipulation using __import__ and __bases__.

1 comment:

Michael Stone said...

Your link to the 'afflicted code' seems to be broken. :(