3 Data Class Details

To be instantiable, class must define (or inherit) the connectionAlias, table and fields attributes, or, can set the _instantiable attribute to 1. The overridability is there so, in the case where you have your own fetching mechanisms (i.e. stored procs), you can make the object instantiable even though it normally wouldn't be (since no table for instance).

The fields member is tuple of (columnname, dbtype) pairs. The unique attribute is a list of strings and/or tuple of strings. If a string, this says that this field is unique in the table, if a tuple, this says these fields taken together are unique in the table.

You can make the dataclass instances immutable by defining the mutable attribute as a false value (None, 0, empty string, etc.)

For databases with named sequences, you can populate the value of an field by defining the sequenced member as a dict of {fieldname: sequence_name} pairs, whereby if, on a call to new(), the fields specified in sequenced are not present, the values are fetched from the sequence(s) before insert and subsequently inserted.

For databases with auto-increment fields, you can populate the value of an field by defining the auto_increment member with a dict of {fieldname: auto_increment_name} pairs and the values will be populated into the object after the insert is executed. In the case of MySQL, there can only be one auto-increment field per table, so the auto_increment_name is needed, but it's value is irrelevant.

To define a static method (one that applies to the dataclass) define the method as

def static_realmethodname

Others are instance methods.

To get an unbound instance method, get data_class.instance_method, to get a static method, unbound from it's original data class (presumably called from a sub-data-classe), use data_class.static_static_method_name.

Attributes (static methods, data members, etc.) on data classes are accessible from instances.