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

36. AccessSummary.__addUrl(): Register one access in self.__urlMap

webstats.py
# - - -   A c c e s s S u m m a r y . _ _ a d d U r l

    def __addUrl ( self, url, isFar ):
        '''Update self.__urlMap.

          [ (url is an URL as a string) and
            (isFar is True for off-campus accessor, else False) ->
              self.__urlMap  +:=  one access for url=url and
                                  isFar=isFar ]
        '''

First we make sure that this URL has an entry in self.__urlMap. If not, we create a new one. Then, in either case, we register the new access in that HitCount instance. See Section 45, “class HitCount: Hit counts for one URL”.

webstats.py
        #-- 1 --
        # [ if self.__urlMap does not have url as a key ->
        #     self.__urlMap  :=  hitCount  :=  a new HitCount
        #         instance for url=url
        #   else ->
        #     hitCount  :=  self.__urlMap[url] ]
        try:
            hitCount  =  self.__urlMap[url]
        except KeyError:
            hitCount  =  self.__urlMap[url]  =  HitCount ( url )

See Section 47, “HitCount.addHit(): Tally one access”.

webstats.py
        #-- 2 --
        # [ if isFar ->
        #     hitCount  :=  hitCount with one total access added
        #                   and one remote access added
        #   else ->
        #     hitCount  :=  hitCount with one total access added ]
        hitCount.addHit ( isFar )