Views and Validators
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:
A
Validator
is an object aBookSet
notifies before changing data, asking for permission to proceed.A
View
is an object theBookSet
notifies after changes have been made.[1] 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 Validator
and
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 BookSet
that
can use them. All this code can be found in the module
doubletalk.userhooks
, which also includes examples of
Validator
s and View
s.
Here’s the definition of a View
:
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 ...
Get Python Programming On Win32 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.