The notifications before the event are intended to validate data, and the notifications after the event can maintain custom views. Accordingly, we define two types of delegate:
Validator is an object a
BookSet notifies before changing data, asking for
permission to proceed.
View is an object the
notifies after changes have been made. It also has a method to return a 2D
array of data on demand, which contains whatever users wish.
It was traditional until recently to have just one delegate for an
object. Some Java development environments allow a list of delegates
that can be added and removed at runtime, and we’ve borrowed
this pattern. We could also have built a more complex delegate that
combined the functions of
View, but this seemed a better fit to our goals
for the users.
For each delegate, youshould provide a base class users can subclass.
You should also define a subclass of
can use them. All this code can be found in the module
, which also includes examples of
Here’s the definition of a
class View: """This delegate is informed of all changes after they occur, and returns a 2d array of data when asked.""" def setBookSet(self, aBookSet): self.BookSet = aBookSet self.recalc() def getDescription(self): return 'abstract base class for Views' # hooks for notification after the event def didAdd(self, aTransaction): pass def didEdit(self, index, newTransaction): pass def ...