Implement proper object subclassing support

Implement support for subclassing objects properly. If some hook, extension,
or alternative DB API backend subclasses one of the base objects, the new
object should be registered and all code should end up using this new
class.

Change-Id: I1d91ade2936e031c4cad29d9e49033bbc002db3c
Partial-Blueprint: object-subclassing
Merge "Implement proper object subclassing support"