This function adds a row to the table containing the
given uid and gecos fields.
# - - - a d d R o w - - -
def addRow ( table, uid, gecos ):
"""Add a result table row.
[ (table is an XHTML table as a DOM Element node) and
(uid is an account name) and
(gecos is that accountholder's personal name) ->
table := table with a new row added displaying gecos
and the URL to uid as a link ]
"""
First we add the tr element with
two td children:
#-- 1 --
# [ table := table with a new tr element added containing
# two td children
# tr := that tr element
# td1 := that first td child
# td2 := that second td child ]
tr = xc.Element ( table, "tr" )
td1 = xc.Element ( tr, "td" )
td2 = xc.Element ( tr, "td" )
In the first cell we put the personal name:
#-- 2 --
# [ td1 := td1 with a new text element added containing gecos ]
xc.Text ( td1, gecos )
Finally, in the second cell we put the URL both as a link and as link text.
#-- 3 --
# [ td2 := td2 with a new tt element added containing a
# link to the homepage url for user (uid) with the
# url as the link text ]
url = "http://www.nmt.edu/~%s/" % uid
tt2 = xc.Element ( td2, "tt" )
a = xc.Element ( tt2, "a", href=url )
xc.Text ( a, url )