UserManagerToFile

The UserManagerToFile class.

class UserKit.UserManagerToFile.UserManagerToFile(userClass=None)

Bases: UserManager

User manager storing user data in the file system.

When using this user manager, make sure you invoke setUserDir() and that this directory is writeable by your application. It will contain one file per user with the user’s serial number as the main filename and an extension of ‘.user’.

The default user directory is the current working directory, but relying on the current directory is often a bad practice.

__init__(userClass=None)
activeUserTimeout()
activeUsers()

Return a list of all active users.

addUser(user)
cachedUserTimeout()
clearCache()

Clear the cache of the manager.

Use with extreme caution. If your program maintains a reference to a user object, but the manager loads in a new copy later on, then consistency problems could occur.

The most popular use of this method is in the regression test suite.

createUser(name, password, userClass=None)

Return a newly created user that is added to the manager.

If userClass is not specified, the manager’s default user class is instantiated. This not imply that the user is logged in. This method invokes self.addUser().

See also: userClass(), setUserClass()

decoder()
encoder()
inactiveUsers()
initNextSerialNum()
loadUser(serialNum, default=<class 'MiscUtils.NoDefault'>)

Load the user with the given serial number from disk.

If there is no such user, a KeyError will be raised unless a default value was passed, in which case that value is returned.

login(user, password)

Return the user if login is successful, otherwise return None.

loginExternalId(externalId, password)
loginName(userName, password)
loginSerialNum(serialNum, password)
logout(user)
modifiedUserTimeout()
nextSerialNum()
numActiveUsers()

Return the number of active users (e.g. the logged in users).

scanSerialNums()

Return a list of all the serial numbers of users found on disk.

Serial numbers are always integers.

setActiveUserTimeout(value)
setCachedUserTimeout(value)
setEncoderDecoder(encoder, decoder)
setModifiedUserTimeout(value)
setUserClass(userClass)

Overridden to mix in UserMixIn to the class that is passed in.

setUserDir(userDir)

Set the directory where user information is stored.

You should strongly consider invoking initNextSerialNum() afterwards.

shutDown()

Perform any tasks necessary to shut down the user manager.

Subclasses may override and must invoke super as their last step.

userClass()

Return the userClass, which is used by createUser.

The default value is UserKit.User.User.

userDir()
userForExternalId(externalId, default=<class 'MiscUtils.NoDefault'>)

Return the user with the given external id.

The user record is pulled into memory if needed.

userForName(name, default=<class 'MiscUtils.NoDefault'>)

Return the user with the given name.

The user record is pulled into memory if needed.

userForSerialNum(serialNum, default=<class 'MiscUtils.NoDefault'>)

Return the user with the given serialNum.

The user record is pulled into memory if needed.

users()

Return a list of all users (regardless of login status).

class UserKit.UserManagerToFile.UserMixIn

Bases: object

filename()
save()