evennia.accounts.manager

The managers for the custom Account object and permissions.

class evennia.accounts.manager.AccountManager(*args, **kwargs)[source]

Bases: evennia.accounts.manager.AccountDBManager, evennia.typeclasses.managers.TypeclassManager

class evennia.accounts.manager.AccountDBManager(*args, **kwargs)[source]

Bases: evennia.typeclasses.managers.TypedObjectManager, django.contrib.auth.models.UserManager

This AccountManager implements methods for searching and manipulating Accounts directly from the database.

Evennia-specific search methods (will return Characters if possible or a Typeclass/list of Typeclassed objects, whereas Django-general methods will return Querysets or database objects):

dbref (converter) dbref_search get_dbref_range object_totals typeclass_search num_total_accounts get_connected_accounts get_recently_created_accounts get_recently_connected_accounts get_account_from_email get_account_from_uid get_account_from_name account_search (equivalent to evennia.search_account)

num_total_accounts()[source]

Get total number of accounts.

Returns

count (int) – The total number of registered accounts.

get_connected_accounts()[source]

Get all currently connected accounts.

Returns

count (list)

Account objects with currently

connected sessions.

get_recently_created_accounts(days=7)[source]

Get accounts recently created.

Parameters

days (int, optional) – How many days in the past “recently” means.

Returns

accounts (list) – The Accounts created the last days interval.

get_recently_connected_accounts(days=7)[source]

Get accounts recently connected to the game.

Parameters

days (int, optional) – Number of days backwards to check

Returns

accounts (list)

The Accounts connected to the game in the

last days interval.

get_account_from_email(uemail)[source]

Search account by Returns an account object based on email address.

Parameters

uemail (str) – An email address to search for.

Returns

account (Account) – A found account, if found.

get_account_from_uid(uid)[source]

Get an account by id.

Parameters

uid (int) – Account database id.

Returns

account (Account) – The result.

get_account_from_name(uname)[source]

Get account object based on name.

Parameters

uname (str) – The Account name to search for.

Returns

account (Account) – The found account.

search_account(ostring, exact=True, typeclass=None)[source]

Searches for a particular account by name or database id.

Parameters
  • ostring (str or int) – A key string or database id.

  • exact (bool, optional) – Only valid for string matches. If True, requires exact (non-case-sensitive) match, otherwise also match also keys containing the ostring (non-case-sensitive fuzzy match).

  • typeclass (str or Typeclass, optional) – Limit the search only to accounts of this typeclass.

Returns

Queryset – A queryset (an iterable) with 0, 1 or more matches.

create_account(key, email, password, typeclass=None, is_superuser=False, locks=None, permissions=None, tags=None, attributes=None, report_to=None)[source]

This creates a new account.

Parameters
  • key (str) – The account’s name. This should be unique.

  • email (str or None) – Email on valid addr@addr.domain form. If the empty string, will be set to None.

  • password (str) – Password in cleartext.

Keyword Arguments
  • typeclass (str) – The typeclass to use for the account.

  • is_superuser (bool) – Whether or not this account is to be a superuser

  • locks (str) – Lockstring.

  • permission (list) – List of permission strings.

  • tags (list) – List of Tags on form (key, category[, data])

  • attributes (list) – List of Attributes on form (key, value [, category, [,lockstring [, default_pass]]])

  • report_to (Object) – An object with a msg() method to report errors to. If not given, errors will be logged.

Returns

Account – The newly created Account.

Raises

ValueError – If key already exists in database.

Notes

Usually only the server admin should need to be superuser, all other access levels can be handled with more fine-grained permissions or groups. A superuser bypasses all lock checking operations and is thus not suitable for play-testing the game.

Searches for a particular account by name or database id.

Parameters
  • ostring (str or int) – A key string or database id.

  • exact (bool, optional) – Only valid for string matches. If True, requires exact (non-case-sensitive) match, otherwise also match also keys containing the ostring (non-case-sensitive fuzzy match).

  • typeclass (str or Typeclass, optional) – Limit the search only to accounts of this typeclass.

Returns

Queryset – A queryset (an iterable) with 0, 1 or more matches.