<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_role(role,**kwargs):
 """ Add a new role """

    #check_perm(kwargs.get('user_id'), 'add_role')
    role_i = Role(name=role.name, code=role.code)
    db.DBSession.add(role_i)
    db.DBSession.flush()

    return role_i