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

25. addRow(): Add one row to the subpage table

homelist2
# - - -   a d d R o w

def addRow(table, kwicRef):
    '''Add one row to the subpage's table of homepage links.

      [ let 
          uid == kwicRef.userData.login
        in ->
          (table is a table et.Element) and
          (kwicWord is a kwic.KwicRef) ->
            table  +:=  a tr et.Element containing two td et.Elements,
                the first a link to the homepage URL for uid
                with that URL as the link text, the second a link
                to the same place with str(kwicRef) as the
                link text ]
    '''

For the HTML generated here, see Section 3.4, “Subpage design”.

homelist2
    #-- 1 --
    # [ table  :=  table with a new tr et.Element added
    #   tr  :=  that tr element
    #   userURL  :=  URL for the homepage of user whose uid is
    #                (kwicRef.userData.login) ]
    tr = subElement(table, E.tr())
    userURL = "%s~%s" % (NMT_URL, kwicRef.userData.login)

    #-- 2 --
    # [ tr  :=  tr with a new td element added containing a link to
    #           userURL, with a monospaced userURL as its link text ]
    subElement ( tr,
        E.td ( E.a ( E.tt ( userURL ), href=userURL ) ) )

    #-- 3 --
    # [ tr  :=  tr with a new td element added containing a link to
    #           userURL, with str(kwicRef) as its link text ]
    subElement ( tr,
        E.td ( E.a ( str(kwicRef), href=userURL ) ) )