A class corresponding to an entity must meet the following requirements:
__init__()
should be designed so that it
is possible to call it with no arguments at all: for example, if the method
accepts arguments, each one should have default values. The reason for this
is that the framework relies on a call to __init__()
without any
arguments, when it needs to create an instance before populating it with
data fetched from the database.
entityName()
taking
no argument: this is the way the framework currently binds an object to its
entity. This should be changed (see TODO)
CustomObject
as well, this
method should be called prior to modifying an object's property. This is
part of the Observing interface, and its purpose is to notify the
EditingContext that the object is about to change: the
EditingContext needs to keep track of changes in its graph of
objects in order to be able to save the changes (ZODB speaking, this is what
the mix-in class Persistent does transparently for immutable
attributes (see also: TODO)).
Of course, willChange automatically invokes willRead.
_lastName
for attribute lastName
), the framework itself does
not require this. Instead, it accesses and sets the values using the
so-called private API of KeyValueCoding; shortly said, this means that in
order to read a property 'name' for example, it tries to find either an
attribute or a method called '_name', '_name()', '_getName()', 'name',
'getName()'. Refer to 8.2 for a complete
overview.