

def __init__(self, siteconfig, *args, **kwargs):
    'Initialize the form.'
    from reviewboard.accounts.backends import get_registered_auth_backends
    super(AuthenticationSettingsForm, self).__init__(siteconfig, *args, **kwargs)
    self.auth_backend_forms = {
        
    }
    cur_auth_backend = (self['auth_backend'].data or self.fields['auth_backend'].initial)
    if (cur_auth_backend == self.CUSTOM_AUTH_ID):
        custom_auth_form = LegacyAuthModuleSettingsForm(siteconfig, *args, **kwargs)
    else:
        custom_auth_form = LegacyAuthModuleSettingsForm(siteconfig)
    self.auth_backend_forms[self.CUSTOM_AUTH_ID] = custom_auth_form
    backend_choices = []
    builtin_auth_choice = None
    for backend in get_registered_auth_backends():
        backend_id = backend.backend_id
        try:
            if backend.settings_form:
                if (cur_auth_backend == backend_id):
                    backend_form = backend.settings_form(siteconfig, *args, **kwargs)
                else:
                    backend_form = backend.settings_form(siteconfig)
                self.auth_backend_forms[backend_id] = backend_form
                backend_form.load()
            choice = (backend_id, backend.name)
            if (backend_id == 'builtin'):
                builtin_auth_choice = choice
            else:
                backend_choices.append(choice)
        except Exception as e:
            logging.error(('Error loading authentication backend %s: %s' % (backend_id, e)), exc_info=1)
    backend_choices.sort(key=(lambda x: x[1]))
    backend_choices.insert(0, builtin_auth_choice)
    backend_choices.append(self.CUSTOM_AUTH_CHOICE)
    self.fields['auth_backend'].choices = backend_choices

dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/admin/forms.py AuthenticationSettingsForm.__init__/original