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

14. isWebUser(): Does this user have a personal Web?

homelist2
# - - -   i s W e b U s e r

def isWebUser(webUser):
    '''See if this user has a personal homepage.

      [ webUser is a WebUser instance ->
          if webUser has a personal homepage ->
            return True
          else -> return False ]
    '''

First of all, we ignore account names that end in “$”; they are special TCC accounts.

homelist2
    #-- 1 --
    if webUser.login[-1] == '$':
        return False

For a user account N, their home directory is at path “/u/N”, and their HTML directory must be a first-level directory whose name is given by Section 7.5, “WEB_DIR.

homelist2
    #-- 1 --
    # [ webPath  :=  absolute path to the HTML directory for user
    #                uid ]
    webPath  =  "/u/%s/%s/" % (webUser.login, WEB_DIR)

    #-- 2 --
    # [ if webPath names an existing path ->
    #     mode  :=  permissions word (mode bits) for webPath
    #   else -> return 0 ]
    try:
        statusTuple  =  os.stat ( webPath )
        mode  =  statusTuple [ stat.ST_MODE ]
    except OSError:
        return 0

    #-- 3 --
    # [ if mode has world read and world execute bits both set ->
    #     return 1
    #   else ->
    #     return 0 ]
    return bool ( (mode & stat.S_IROTH) and
                  (mode & stat.S_IXOTH) )