

def __init__(self, request, *args, **kwargs):
    super(UpdateL3PolicyForm, self).__init__(request, *args, **kwargs)
    try:
        l3policy_id = self.initial['l3policy_id']
        l3 = client.l3policy_get(request, l3policy_id)
        for item in ['name', 'description', 'ip_version', 'ip_pool', 'subnet_prefix_length']:
            self.fields[item].initial = str(l3[item])
        self.fields['shared'].initial = l3['shared']
        if bool(l3['external_segments']):
            es_choices = []
            es_initial = []
            for (key, value) in l3['external_segments'].items():
                val = ((('ES:' + key) + ',IP:') + value[0])
                es_choices.append((val, val))
                es_initial.append(val)
            val.fields['external_segments'].choices = es_choices
            self.fields['external_segments'].initial = es_initial
    except Exception:
        msg = _('Failed to get L3 policy')
        LOG.error(msg)
        exceptions.handle(request, msg, redirect=shortcuts.redirect)

dataset/ETHPy150Open openstack/group-based-policy-ui/gbpui/panels/network_policy/forms.py UpdateL3PolicyForm.__init__/VarMisuse@186/252 `self`->`val`