SQLAlchemy: use the event API to replace the AttributeExtension

AttributeExtension has been deprecated since SQLAlchemy 0.7 and pylint
is complaining it in SQLAlchemy 0.9.

Change-Id: Iae489db35e8bf7da374004803e1d55ec91540723