def METHOD_NAME(obj, obj_type, obj_id, **kwargs):
    if not hasattr(obj, "entity"):
        return url_for("attachments.entity", object_id=obj_id)
    entity = obj.entity
    return url_for(entity, _anchor=f"attachment-{obj.id}")