def _check_caller_authority(caller, role):
 if (not (caller.is_authenticated() and caller.is_active)):
  raise PermissionDenied
 if GlobalStaff().has_user(caller):
  return
 if isinstance(role, (GlobalStaff, CourseCreatorRole)):
  raise PermissionDenied
 elif isinstance(role, CourseRole):
  if (not user_has_role(caller, CourseInstructorRole(role.course_key))):
   raise PermissionDenied

def _check_caller_authority ( caller , role ) : if ( not ( caller . is_authenticated ( ) and caller . is_active ) ) : raise PermissionDenied if GlobalStaff ( ) . has_user ( caller ) : return if isinstance ( role , ( GlobalStaff , CourseCreatorRole ) ) : raise PermissionDenied elif isinstance ( role , CourseRole ) : if ( not user_has_role ( caller , CourseInstructorRole ( role . course_key ) ) ) : raise PermissionDenied
internal function to check whether the caller has authority to manipulate this role .