def abort_if_bucketlist_doesnt_exist(bucketlist_id): bucketlist = Bucketlist.get_bucketlist(bucketlist_id) if not bucketlist: abort(404, message="Bucketlist '{}' does not exist".format( bucketlist_id)) elif check_user_permission(bucketlist.user): return bucketlist