This function adds the group of two radiobuttons that allow the user to select whether they get a persistent cookie or a session cookie.
# - - - r a d i o G r o u p
def radioGroup ( parent, userRecord ):
'''Add the REQUEST_GROUP radiobutton group.
[ parent is an et.Element ->
parent +:= the radiobuttons in REQUEST_GROUP in the
same state as userRecord.persist ]
'''
For control names and labels, see Section 7.6.6, “REQUEST_GROUP” and adjacent entries.
#-- 1 --
# [ parent +:= two new 'div' children
# div1 := the first child
# div2 := the second child ]
div1 = et.SubElement ( parent, 'div' )
div2 = et.SubElement ( parent, 'div' )
#-- 2 --
# [ div1 +:= a new radiobutton with name REQUEST_GROUP and
# value REQUEST_SESSION
# radioSession := that radiobutton ]
radioSession = et.SubElement ( div1, 'input', type='radio',
name=REQUEST_GROUP, value=REQUEST_SESSION, id='req-s')
radioLabel = et.SubElement ( div1, 'label' )
radioLabel.attrib['for'] = 'req-s'
radioLabel.text = SESSION_LABEL
#-- 3 --
# [ div2 +:= a new radiobutton with name REQUEST_GROUP and
# value REQUEST_PERSIST
# radioPersist := that radiobutton ]
radioPersist = et.SubElement ( div2, 'input', type='radio',
name=REQUEST_GROUP, value=REQUEST_PERSIST, id='req-p' )
radioLabel = et.SubElement ( div2, 'label' )
radioLabel.attrib['for'] = 'req-p'
radioLabel.text = PERSIST_LABEL
#-- 4 --
# [ if userRecord.persist ->
# radioPersist := radioPersist, checked initially
# else ->
# radioSession := radioSession, checked initially ]
if userRecord.persist:
radioPersist.attrib['checked'] = 'checked'
else:
radioSession.attrib['checked'] = 'checked'