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

3.5.  scanAccounts(): Find all homepages

This routine takes the table node, containing the XHTML table we're building, and scans through all user accounts in the LDAP server, adding rows to the table for users who have homepages.

homelist.py
# - - -   s c a n A c c o u n t s   - - -

def scanAccounts ( table ):
    """Scan through all the user accounts, looking for homepages.

      [ table is a DOM Element node ->
         table  :=  table with XHTML rows added representing a list of
             user names and homepage links for all users in the TCC's
             LDAP server who have a homepage ]
    """

First we call generateAccounts(), which iterates through the LDAP accounts list and returns an unordered list of (uid, gecos) 2-tuples, one for each user account.

homelist.py
    #-- 1 --
    # [ userList  :=  a list of (uid, gecos) 2-tuples, one for
    #       each active account in the LDAP server LDAP_SERVER ]
    userList  =  generateAccounts()

Next, we sort the list by uid:

homelist.py
    #-- 2 --
    userList.sort()

Finally, we work through this list, and for each uid that has a homepage, we add another row to the table.

homelist.py
    #-- 3 --
    for  uid, gecos in userList:
        #-- 3 body --
        # [ (uid is an account name) and
        #   (gecos is that account's personal name) ->
        #     if (uid doesn't end in '$') and
        #     (account uid has a homepage) ->
        #       table  +:=  an XHTML row added for account=uid
        #           and name=gecos ]
        if  ( ( uid[-1] != '$' ) and
              hasHomepage ( uid ) ):
            addRow ( table, uid, gecos )