I think we can do better than munging some addition code to the end of a file. We should be able to do all of this by attaching some regular python observers to the view in the code below.