History for ControllerCode
??changed:
-
<hr>
<pre>
import ModelDeleted
import Event
import Callback
class Controller:
"""Write"""
def __init__(self, aModel):
"""Construct the instance"""
self.__model = aModel
eventList = [Event.Event(ModelDeleted.ModelDeleted(),
self.Callback(self.modelDeleted))]
eventList.extend(self.registerEvents())
for anEvent in eventList:
self.__model.addViewEvent(self, anEvent)
return
def __del__(self):
"""Destroy the instance"""
## print "View.__del__"
self.finished()
return
def finished(self):
"""Manually break the loops."""
if self.__model:
self.__model.removeView(self)
self.__model = None
return
def registerEvents(self):
"""Register the events that this view is interested in."""
return []
def modelDeleted(self, aReason):
"""Method that is invoked when the model is deleted."""
self.__model = None
return
def getModel(self):
"""Return the model."""
return self.__model
class Callback(Callback.Callback):
"""Nested class to handle callbacks."""
def __init__(self, callback):
"""Construct the instance."""
self.__callback = callback
return
def execute(self, aReason):
"""Evecute the callaback."""
self.__callback(aReason)
return
</pre>
<hr>