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

11. buildKwic(): Survey the users and build the KWIC index

homelist2
# - - -   b u i l d K w i c

def buildKwic():
    '''Build the index of personal web page users.

      [ return a kwic.KwicIndex instance indexing the names of users
        in LDAP_SERVER who have a readable WEB_DIR subdirectory,
        with the user data for each user represented as a WebUser
        instance ]
    '''

First we build an empty KWIC index instance.

homelist2
    #-- 1 --
    # [ if kwic.KwicIndex can find its stop word list ->
    #     kwicIndex  :=  a new kwic.KwicIndex instance with those
    #                    stop words
    #   else ->
    #     kwicIndex  :=  a new kwic.KwicIndex instance with no stop
    #                    words ] 
    kwicIndex = kwic.KwicIndex()

Section 12, “genWebUsers(): Find users with homepages” handles extraction of the usernames from LDAP and selecting the ones that have a personal homepage. For each such user, it creates an instance of Section 26, “class WebUser: Encapsulate user data”. These instances are then passed to Section 15, “indexUser(): Add one user to the KWIC index” to be added to kwicIndex.

homelist2
    #-- 2 --
    # [ kwicIndex  :=  kwicIndex with entries added that index names
    #       of users in LDAP_SERVER who have a readable WEB_DIR
    #       subdirectory ]
    for webUser in genWebUsers():
        indexUser(kwicIndex, webUser)

    #-- 3 --
    return kwicIndex