evennia.accounts.manager

The managers for the custom Account object and permissions.

class evennia.accounts.manager.AccountManager(*args, **kwargs)[源代码]

基类:evennia.accounts.manager.AccountDBManager, evennia.typeclasses.managers.TypeclassManager

class evennia.accounts.manager.AccountDBManager(*args, **kwargs)[源代码]

基类: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()[源代码]

Get total number of accounts.

返回

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

get_connected_accounts()[源代码]

Get all currently connected accounts.

返回

count (list)

Account objects with currently

connected sessions.

get_recently_created_accounts(days=7)[源代码]

Get accounts recently created.

参数

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

返回

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

get_recently_connected_accounts(days=7)[源代码]

Get accounts recently connected to the game.

参数

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

返回

accounts (list)

The Accounts connected to the game in the

last days interval.

get_account_from_email(uemail)[源代码]

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

参数

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

返回

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

get_account_from_uid(uid)[源代码]

Get an account by id.

参数

uid (int) – Account database id.

返回

account (Account) – The result.

get_account_from_name(uname)[源代码]

Get account object based on name.

参数

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

返回

account (Account) – The found account.

search_account(ostring, exact=True, typeclass=None)[源代码]

Searches for a particular account by name or database id.

参数
  • 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.

返回

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)[源代码]

This creates a new account.

参数
  • 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.

关键字参数
  • 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.

返回

Account – The newly created Account.

引发

ValueError – If key already exists in database.

提示

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.

参数
  • 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.

返回

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