def before_persist_object_listener(mapper, connection, obj):
    """
    This listener method is used to ensure, that an objects 'on_persist' method
    is executed before the object is written to the database.
    """
    obj.on_persist()
