Throw exceptions when non Datasource classes are used as Datasources.

Using models as datasources can cause segmentation faults. Guard against
that by checking types and raising exceptions early.

Fixes #3694