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: