Next / Previous / Contents / TCC Help System / NM Tech homepage

11.8. TaxonPhotoSet.buildPage(): Construct XHTML

This method is called to render one taxon's content on the index page, and also to build all form pages (and links to them) for forms referred to this taxon.

# - - -   T a x o n P h o t o S e t . b u i l d P a g e

    def buildPage(self, parent):
        '''Add one taxon to the index page, and build all its form pages

          [ parent is an et.Element ->
              parent  :=  parent with XHTML child nodes added to
                          represent self
              form pages for forms referred to self's taxon  :=
                  content displaying thumbnails and catalog info
                  for forms in self ]

In one case, this method builds nothing at all: if it is a genus-level taxon that has no forms referred to it. See Section 3.1, “The index page” for remarks on this case.

        #-- 1
        # [ if self is a genus-level taxon with no forms referred
        #   to it ->
        #     return
        #   else -> I ]
        if (( self.taxon.rank.depth ==
                self.taxon.txny.hier.genusRank().depth) and
             (len(self._formMap) == 0)):

All the content for this taxon will be wrapped in a div element of class head-R, where R is the code for the taxonomic rank of self's taxon.

        #-- 2
        # [ parent  :=  parent with a div added, tagged with
        #       the heading class for self's taxonomic rank
        #   div  :=  that new div element ]
        classRank = "head-{0}".format(self.taxon.rank.code)
        div = subElement(parent,

Here we divide the logic into three cases.

If there is a single form in this taxon, the content is the taxonomic heading as a link to the form page for that form. If there are multiple forms, the content starts with the taxonomic heading, followed by one additional div element for each form's name as a link to the corresponding form page.

        #-- 3
        # [ if len(self._formMap) == 0 ->
        #     div  :=  div + (self's inverted name)
        #   else if len(self._formMap) <= 1 ->
        #     div  :=  div + (link to form page containing self's
        #              inverted name, and the form name if
        #              different than self's inverted name
        #     form page for self._formMap's value  :=  content
        #         displaying thumbnails and catalog info for
        #         self._formMap's value
        #   else ->
        #     div  :=  div + (self's inverted name) +
        #         (links to form pages for forms in self._formMap)
        #     form pages for self._formMap values  :=  content
        #         displaying thumbnails and catalog info for
        #         values in self._formMap ]
        if  len(self._formMap) == 0:
        elif  len(self._formMap) == 1: