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

15. instituteHomepage(): Access report for “/

This is a special one-line access report for URL “/”. It is remotely possible that the homepage will have no hits, so show zero hits in that case. The URL INSTITUTE_HOMEPAGE is defined in Section 6.3, “Web paths”.

webstats.py
# - - -   i n s t i t u t e H o m e p a g e

def instituteHomepage ( parent, accessSummary ):
    '''Build the access report for INSTITUTE_HOMEPAGE.

      [ (parent is an et.Element) and
        (accessSummary is an AccessSummary) ->
          parent  +:=  (official-content for "/" from accessSummary) ]
    '''
    #-- 1 --
    # [ if accessSummary has any access for INSTITUTE_HOMEPAGE ->
    #     hitCount  :=  its access counts as a HitCount
    #   else ->
    #     hitCount  :=  a new HitCount showing zero accesses ]
    try:
        hitCount  =  accessSummary.getUrl ( INSTITUTE_HOMEPAGE )
    except KeyError:
        hitCount  =  HitCount ( INSTITUTE_HOMEPAGE )

Building the access report uses Section 13, “accessReport(): Start a new access report table” and Section 14, “accessRow(): Add one row to an access report table”.

webstats.py
    #-- 2 --
    # [ parent  +:=  heading "Access report for the NMT homepage" ]
    parent.append ( E.p ( "Access report for the NMT homepage" ) )

    #-- 3 --
    # [ parent  +:=  a new access report as a 'table'
    #   tbody  :=  the 'tbody' element of that table ]
    tbody  =  accessReport ( parent )

    #-- 4 --
    # [ tbody  +:=  an access report row displaying hitCount ]
    accessRow ( tbody, hitCount )