def delete_request_type_permissions( id ):
    rtps = sa_session.query( galaxy.model.RequestTypePermissions ) \
                     .filter( and_( galaxy.model.RequestTypePermissions.table.c.request_type_id==id ) ) \
                     .order_by( desc( galaxy.model.RequestTypePermissions.table.c.create_time ) )
    for rtp in rtps:
        sa_session.delete( rtp )
    sa_session.flush()
def delete_obj( obj ):
    sa_session.delete( obj )
    sa_session.flush()
def delete_user_roles( user ):
    for ura in user.roles:
        sa_session.delete( ura )
    sa_session.flush()