def set_form_control_value(control, val):
 if isinstance(control, ClientForm.CheckboxControl):
  try:
   checkbox = control.get()
   checkbox.selected = make_boolean(val)
   return
  except ClientForm.AmbiguityError:
   pass
 if isinstance(control, ClientForm.ListControl):
  if val.startswith('-'):
   val = val[1:]
   flag = False
  else:
   flag = True
   if val.startswith('+'):
    val = val[1:]
  try:
   item = control.get(name=val)
  except ClientForm.ItemNotFoundError:
   try:
    item = control.get(label=val)
   except ClientForm.AmbiguityError:
    raise ClientForm.ItemNotFoundError(('multiple matches to value/label "%s" in list control' % (val,)))
   except ClientForm.ItemNotFoundError:
    raise ClientForm.ItemNotFoundError(('cannot find value/label "%s" in list control' % (val,)))
  if flag:
   item.selected = 1
  else:
   item.selected = 0
 else:
  control.value = val

def set_form_control_value ( control , val ) : if isinstance ( control , ClientForm . CheckboxControl ) : try : checkbox = control . get ( ) checkbox . selected = make_boolean ( val ) return except ClientForm . AmbiguityError : pass if isinstance ( control , ClientForm . ListControl ) : if val . startswith ( '-' ) : val = val [ 1 : ] flag = False else : flag = True if val . startswith ( '+' ) : val = val [ 1 : ] try : item = control . get ( name = val ) except ClientForm . ItemNotFoundError : try : item = control . get ( label = val ) except ClientForm . AmbiguityError : raise ClientForm . ItemNotFoundError ( ( 'multiple matches to value/label "%s" in list control' % ( val , ) ) ) except ClientForm . ItemNotFoundError : raise ClientForm . ItemNotFoundError ( ( 'cannot find value/label "%s" in list control' % ( val , ) ) ) if flag : item . selected = 1 else : item . selected = 0 else : control . value = val
helper function to deal with setting form values on checkboxes .