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

17. buildRoomPage(): Make the page with a table of all the clients in a room

This function builds a room page, consisting mainly of a table displaying the configurations of all the clients in a given room. For the XHTML generated here, see Section 3.2, “XHTML for the room page”.

hwscan3.py
# - - -   b u i l d R o o m P a g e

def buildRoomPage ( room, reportInfo, clientSet ):
    '''Build the page containing a table of clients in a room.

      [ (room is a Room instance describing the room) and
        (reportInfo is a ReportInfo instance) and
        (clientSet is a ClientSet) ->
          room file for room  :=  table of clients in room
            room.roomPrefix from clientSet, with roomType in
            the page title, with devices from reportInfo ]
    '''

The tccpage2 module builds a basic page in the TCC standard format. For a discussion of the navigational features used, see Section 3.2, “XHTML for the room page”. The page's file name will be the room prefix, e.g., "speare116.html"; see Section 16, “roomPagePath(): Absolute path name of a room page”.

For the definitions of relevant constants, see Section 6.8, “START_URL; Section 6.2, “TCC_URL; and Section 6.10, “CSS_URL.

hwscan3.py
    #-- 1 --
    # [ page  :=  a new tccpage2.TCCPage instance with navigational
    #       links pointing to the parent page and the TCC
    #       homepage, and using the TCC stylesheet ]
    title  =  ( "TCC workstation inventory for %s %s" % 
                (room.roomFull, room.roomFullType) )
    roomURL  =  roomPageURL ( room )
    navList  =  [
        tccpage2.NavLink ( "TCC hardware",
            [("Server and workstation inventory", START_URL)] ),
        tccpage2.NavLink ( "TCC home",
            [("New Mexico Tech Computer Center", TCC_HOME)] ) ]
    page  =  tccpage2.TCCPage ( title, navList, url=roomURL,
                                cssUrl=CSS_URL )

For the generation of the page's XHTML content, see Section 18, “buildRoomTable(): Build the table of client configurations”.

hwscan3.py
    #-- 4 --
    # [ page.content  +:=  table of clients in room room.roomPrefix
    #       from clientSet, with devices from reportInfo ]
    buildRoomTable ( page.content, room, reportInfo, clientSet )

Finally, write the room page to its destination.

hwscan3.py
    #-- 5 --
    # [ if we can create a new file named clientPath ->
    #     file clientPath  :=  page as XHTML
    #   else ->
    #     sys.stderr  +:=  error message ]
    roomFileName  =  roomPagePath ( room )
    try:
        roomFile  =  open ( roomFileName, 'w' )
        page.write ( roomFile )
        roomFile.close()
    except IOError, detail:
        print >>sys.stderr, ( "*** Can't create room page "
            "'%s': %s" % (roomFileName, detail) )