For an overview of the generated output, see Section 4.8, “XHTML for the form element”. A div
class=FORM_CLASS wraps all generated content,
except for notable records, which get class=NOTABLE_FORM_CLASS.
# - - - M o n t h C e l l . _ _ b i r d F o r m
def __birdForm ( self, parent, birdForm ):
'''Output all the data from one BirdForm instance.
[ (parent is an et.Element) and
(birdForm is a birdnotes.BirdForm instance) ->
parent +:= XHTML rendering of birdForm ]
'''
#-- 1 --
# [ parent +:= a new div element with class=FORM_CLASS
# div := that div element ]
div = et.SubElement ( parent, 'div' )
if birdForm.notable:
div.attrib['class'] = NOTABLE_FORM_CLASS
else:
div.attrib['class'] = FORM_CLASS
Next comes the name of this bird form. We'll wrap it in
a span class='notable' if the birdForm.notable flag is true, otherwise we'll
use the regular span class='bird-name'.
The name of the bird form is a birdnotes.BirdId instance in birdForm.birdId; applying the str() function to a BirdId gives the full
name, even for compound forms such as 'Gadwall x
Mallard'. See Section 23.9, “MonthCell.__span(): Add a span inline”.
#-- 2 --
# [ if birdForm.notable ->
# div +:= birdForm.birdId's name, wrapped in a
# span class=NOTABLE_CLASS
# else ->
# div +:= birdForm.birdId's name, wrapped in a
# span class=BIRD_NAME_CLASS ]
if birdForm.notable:
class_ = NOTABLE_CLASS
else:
class_ = BIRD_NAME_CLASS
self.__span ( div, class_, birdForm.birdId.engComma() )
tccpage2.addTextMixed ( div, NBSP )
At this point, the rendering depends on whether this one sighting or multiple sightings:
If a single sighting, we want the age-sex-group content on the same line as
the bird name. If there is loc-group
or sighting-notes content, it should
follow in separate div elements.
See Section 23.20, “MonthCell.__singleSighting():
Single-sighting case”.
For multiple sightings, there may be loc-group or sighting-notes
content attached both at the form
level and at the floc level.
In that case, we must render any loc-group or sighting-notes
content at the form level first.
Then, each floc element is rendered in
the order age-sex-group, loc-detail, and sighting-notes. See Section 23.21, “MonthCell.__multiSighting():
Multiple-sighting case”.
#-- 3 --
# [ if birdForm contains one sighting ->
# div +:= (that sighting's age-sex-group) +
# (that sighting's loc-group, if any) +
# (that sighting's sighting-notes, if any)
# else ->
# div +:= (birdForm's loc-group content, if any) +
# (birdForm's sighting-notes, if any) +
# (birdForm's sightings packaged in separate divs) ]
if len(birdForm) == 1:
self.__singleSighting ( div, birdForm )
else:
self.__multiSighting ( div, birdForm )