Go to the latest version of this document.

# ``twisted`.`python`.`fakepwd`.`UserDatabase``

class documentation

`class UserDatabase: (source)`

View In Hierarchy

`UserDatabase` holds a traditional POSIX user data in memory and makes it available via the same API as `pwd`.

Method | `__init__` | Undocumented
Method | `addUser` | Add a new user record to this database.
Method | `getpwall` | Return a list of all user records.
Method | `getpwnam` | Return the user record corresponding to the given username.
Method | `getpwuid` | Return the user record corresponding to the given uid.
Class Variable | `_lastGID` | Undocumented
Class Variable | `_lastUID` | Undocumented
Instance Variable | `_users` | A `list` of `_UserRecord` instances holding all user data added to this database.

def __init__(self): (source)

Undocumented

def addUser(self, username: `str`, password: `str` = 'password', uid: `int | None` = None, gid: `int | None` = None, gecos: `str` = '', home: `str` = '', shell: `str` = '/bin/sh'): (source)

Add a new user record to this database.

Parameters
username:`str` | The value for the `pw_name` field of the user record to add.
password:`str` | The value for the `pw_passwd` field of the user record to add.
uid:`int | None` | The value for the `pw_uid` field of the user record to add.
gid:`int | None` | The value for the `pw_gid` field of the user record to add.
gecos:`str` | The value for the `pw_gecos` field of the user record to add.
home:`str` | The value for the `pw_dir` field of the user record to add.
shell:`str` | The value for the `pw_shell` field of the user record to add.

def getpwall(self) -> `list[_UserRecord]`: (source)

Return a list of all user records.

def getpwnam(self, name: `str`) -> `_UserRecord`: (source)

Return the user record corresponding to the given username.

def getpwuid(self, uid: `int`) -> `_UserRecord`: (source)

Return the user record corresponding to the given uid.

_lastGID: `int` = (source)

Undocumented

_lastUID: `int` = (source)

Undocumented

_users: `list[_UserRecord]` = (source)

A `list` of `_UserRecord` instances holding all user data added to this database.