evennia.accounts.models

Account

The account class is an extension of the default Django user class, and is customized for the needs of Evennia.

We use the Account to store a more mud-friendly style of permission system as well as to allow the admin more flexibility by storing attributes on the Account. Within the game we should normally use the Account manager’s methods to create users so that permissions are set correctly.

To make the Account model more flexible for your own game, it can also persistently store attributes of its own. This is ideal for extra account info and OOC account configuration variables etc.

class evennia.accounts.models.AccountDB(*args, **kwargs)[source]

Bases: TypedObject, AbstractUser

This is a special model using Django’s ‘profile’ functionality and extends the default Django User model. It is defined as such by use of the variable AUTH_PROFILE_MODULE in the settings. One accesses the fields/methods. We try use this model as much as possible rather than User, since we can customize this to our liking.

The TypedObject supplies the following (inherited) properties:

  • key - main name

  • typeclass_path - the path to the decorating typeclass

  • typeclass - auto-linked typeclass

  • date_created - time stamp of object creation

  • permissions - perm strings

  • dbref - #id of object

  • db - persistent attribute storage

  • ndb - non-persistent attribute storage

The AccountDB adds the following properties:

  • is_connected - If any Session is currently connected to this Account

  • name - alias for user.username

  • sessions - sessions connected to this account

  • is_superuser - bool if this account is a superuser

  • is_bot - bool if this account is a bot and not a real account

db_is_connected

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_cmdset_storage

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_is_bot

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <evennia.accounts.manager.AccountDBManager object>
property cmdset_storage

Getter. Allows for value = self.name. Returns a list of cmdset_storage.

property name
property key
property uid

Getter. Retrieves the user id

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

account_subscription_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

date_joined

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_attributes

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

db_date_created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_lock_storage

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_tags

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

db_typeclass_path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_next_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
get_previous_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=False, **kwargs)
groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

hide_from_accounts_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property is_bot

A wrapper for getting database field db_is_bot.

property is_connected

A wrapper for getting database field db_is_connected.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_superuser

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_login

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

logentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

**Parent.children** is a **ReverseManyToOneDescriptor** instance.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

objectdb_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

**Parent.children** is a **ReverseManyToOneDescriptor** instance.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

path = 'evennia.accounts.models.AccountDB'
receiver_account_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

scriptdb_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

**Parent.children** is a **ReverseManyToOneDescriptor** instance.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

sender_account_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

typename = 'SharedMemoryModelBase'
user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class evennia.accounts.models.AbstractUser(*args, **kwargs)[source]

Bases: AbstractBaseUser, PermissionsMixin

An abstract base class implementing a fully featured User model with admin-compliant permissions.

Username and password are required. Other fields are optional.

EMAIL_FIELD = 'email'
class Meta[source]

Bases: object

abstract = False
verbose_name = 'user'
verbose_name_plural = 'users'
REQUIRED_FIELDS = ['email']
USERNAME_FIELD = 'username'
clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

date_joined

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email_user(subject, message, from_email=None, **kwargs)[source]

Send an email to this user.

first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_full_name()[source]

Return the first_name plus the last_name, with a space in between.

get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
get_short_name()[source]

Return the short name for the user.

groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_superuser

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_login

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects
password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

username_validator = <django.contrib.auth.validators.UnicodeUsernameValidator object>
class evennia.accounts.models.AccountDBManager(*args, **kwargs)[source]

Bases: TypedObjectManager, 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)

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.

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_name(uname)[source]

Get account object based on name.

Parameters:

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

Returns:

account (Account) – The found account.

get_account_from_uid(uid)[source]

Get an account by id.

Parameters:

uid (int) – Account database id.

Returns:

account (Account) – The result.

get_connected_accounts()[source]

Get all currently connected accounts.

Returns:

count (list)

Account objects with currently

connected sessions.

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_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.

num_total_accounts()[source]

Get total number of accounts.

Returns:

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

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.

class evennia.accounts.models.TypedObject(*args, **kwargs)[source]

Bases: SharedMemoryModel

Abstract Django model.

This is the basis for a typed object. It also contains all the mechanics for managing connected attributes.

The TypedObject has the following properties:

  • key - main name

  • name - alias for key

  • typeclass_path - the path to the decorating typeclass

  • typeclass - auto-linked typeclass

  • date_created - time stamp of object creation

  • permissions - perm strings

  • dbref - #id of object

  • db - persistent attribute storage

  • ndb - non-persistent attribute storage

class Meta[source]

Bases: object

Django setup info.

abstract = False
ordering = ['-db_date_created', 'id', 'db_typeclass_path', 'db_key']
verbose_name = 'Evennia Database Object'
__init__(*args, **kwargs)[source]

The __init__ method of typeclasses is the core operational code of the typeclass system, where it dynamically re-applies a class based on the db_typeclass_path database field rather than use the one in the model.

Parameters:

parent. (Passed through to)

Keyword Arguments:

parent. (Passed through to)

Notes

The loading mechanism will attempt the following steps:

  1. Attempt to load typeclass given on command line

  2. Attempt to load typeclass stored in db_typeclass_path

  3. Attempt to load __settingsclasspath__, which is by the default classes defined to be the respective user-set base typeclass settings, like BASE_OBJECT_TYPECLASS.

  4. Attempt to load __defaultclasspath__, which is the base classes in the library, like DefaultObject etc.

  5. If everything else fails, use the database model.

Normal operation is to load successfully at either step 1 or 2 depending on how the class was called. Tracebacks will be logged for every step the loader must take beyond 2.

access(accessing_obj, access_type='read', default=False, no_superuser_bypass=False, **kwargs)[source]

Determines if another object has permission to access this one.

Parameters:
  • accessing_obj (str) – Object trying to access this one.

  • access_type (str, optional) – Type of access sought.

  • default (bool, optional) – What to return if no lock of access_type was found

  • no_superuser_bypass (bool, optional) – Turn off the superuser lock bypass (be careful with this one).

Keyword Arguments:

kwar (any) – Ignored, but is there to make the api consistent with the object-typeclass method access, which use it to feed to its hook methods.

aliases[source]
at_idmapper_flush()[source]

This is called when the idmapper cache is flushed and allows customized actions when this happens.

Returns:

do_flush (bool)

If True, flush this object as normal. If

False, don’t flush and expect this object to handle the flushing on its own.

Notes

The default implementation relies on being able to clear Django’s Foreignkey cache on objects not affected by the flush (notably objects with an NAttribute stored). We rely on this cache being stored on the format “_<fieldname>_cache”. If Django were to change this name internally, we need to update here (unlikely, but marking just in case).

at_init()[source]

Called when this object is loaded into cache. This is more reliable than to override __init__.

at_rename(oldname, newname)[source]

This Hook is called by @name on a successful rename.

Parameters:
  • oldname (str) – The instance’s original name.

  • newname (str) – The new name for the instance.

attributes[source]
check_permstring(permstring)[source]

This explicitly checks if we hold particular permission without involving any locks.

Parameters:

permstring (str) – The permission string to check against.

Returns:

result (bool) – If the permstring is passed or not.

property date_created

Get the localized date created, based on settings.TIME_ZONE.

property db

Attribute handler wrapper. Allows for the syntax

obj.db.attrname = value
# and
value = obj.db.attrname
# and
del obj.db.attrname
# and
all_attr = obj.db.all()
# (unless there is an attribute
#  named 'all', in which case that will be returned instead).
db_attributes

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

db_date_created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_lock_storage

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

db_tags

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.

Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.

db_typeclass_path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property dbid

Caches and returns the unique id of the object. Use this instead of self.id, which is not cached.

property dbref

Returns the object’s dbref on the form #NN.

delete()[source]

Cleaning up handlers on the typeclass level

get_absolute_url()

Returns the URI path for a View that allows users to view details for this object.

Returns:

path (str) – URI path to object detail page, if defined.

Examples

Oscar (Character) = '/characters/oscar/1/'

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-detail’ would be referenced by this method.

url(r'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/$',
    CharDetailView.as_view(), name='character-detail')

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can view this object is the developer’s responsibility.

get_display_name(looker, **kwargs)[source]

Displays the name of the object in a viewer-aware manner.

Parameters:

looker (TypedObject, optional) – The object or account that is looking at/getting inforamtion for this object. If not given, some ‘safe’ minimum level should be returned.

Returns:

name (str)

A string containing the name of the object,

including the DBREF if this user is privileged to control said object.

Notes

This function could be extended to change how object names appear to users in character, but be wary. This function does not change an object’s keys or aliases when searching, and is expected to produce something useful for builders.

get_extra_info(looker, **kwargs)[source]

Used when an object is in a list of ambiguous objects as an additional information tag.

For instance, if you had potions which could have varying levels of liquid left in them, you might want to display how many drinks are left in each when selecting which to drop, but not in your normal inventory listing.

Parameters:

looker (TypedObject) – The object or account that is looking at/getting information for this object.

Returns:

info (str)

A string with disambiguating information,

conventionally with a leading space.

get_next_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=True, **kwargs)
get_previous_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=False, **kwargs)
init_evennia_properties()[source]

Called by creation methods; makes sure to initialize Attribute/TagProperties by fetching them once.

is_typeclass(typeclass, exact=False)[source]

Returns true if this object has this type OR has a typeclass which is an subclass of the given typeclass. This operates on the actually loaded typeclass (this is important since a failing typeclass may instead have its default currently loaded) typeclass - can be a class object or the python path to such an object to match against.

Parameters:
  • typeclass (str or class) – A class or the full python path to the class to check.

  • exact (bool, optional) – Returns true only if the object’s type is exactly this typeclass, ignoring parents.

Returns:

is_typeclass (bool)

If this typeclass matches the given

typeclass.

property key
property lock_storage

A wrapper for getting database field db_lock_storage.

locks[source]
property name
nattributes[source]
property ndb

NonDataBase). Everything stored to this is guaranteed to be cleared when a server is shutdown. Syntax is same as for the _get_db_holder() method and property, e.g. obj.ndb.attr = value etc.

Type:

A non-attr_obj store (ndb

objects
path = 'evennia.typeclasses.models.TypedObject'
permissions[source]
classmethod search(query, **kwargs)[source]

Overridden by class children. This implements a common API.

Parameters:
  • query (str) – A search query.

  • **kwargs – Other search parameters.

Returns:

list – A list of 0, 1 or more matches, only of this typeclass.

set_class_from_typeclass(typeclass_path=None)[source]
swap_typeclass(new_typeclass, clean_attributes=False, run_start_hooks='all', no_default=True, clean_cmdsets=False)[source]

This performs an in-situ swap of the typeclass. This means that in-game, this object will suddenly be something else. Account will not be affected. To ‘move’ an account to a different object entirely (while retaining this object’s type), use self.account.swap_object().

Note that this might be an error prone operation if the old/new typeclass was heavily customized - your code might expect one and not the other, so be careful to bug test your code if using this feature! Often its easiest to create a new object and just swap the account over to that one instead.

Parameters:
  • new_typeclass (str or classobj) – Type to switch to.

  • clean_attributes (bool or list, optional) – Will delete all attributes stored on this object (but not any of the database fields such as name or location). You can’t get attributes back, but this is often the safest bet to make sure nothing in the new typeclass clashes with the old one. If you supply a list, only those named attributes will be cleared.

  • run_start_hooks (str or None, optional) – This is either None, to not run any hooks, “all” to run all hooks defined by at_first_start, or a string with space-separated hook-names to run (for example ‘at_object_creation’). This will always be called without arguments.

  • no_default (bool, optiona) – If set, the swapper will not allow for swapping to a default typeclass in case the given one fails for some reason. Instead the old one will be preserved.

  • clean_cmdsets (bool, optional) – Delete all cmdsets on the object.

tags[source]
property typeclass_path

A wrapper for getting database field db_typeclass_path.

typename = 'SharedMemoryModelBase'
web_get_admin_url()[source]

Returns the URI path for the Django Admin page for this object.

ex. Account#1 = ‘/admin/accounts/accountdb/1/change/’

Returns:

path (str) – URI path to Django Admin page for object.

classmethod web_get_create_url()[source]

Returns the URI path for a View that allows users to create new instances of this object.

ex. Chargen = ‘/characters/create/’

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-create’ would be referenced by this method.

ex. url(r’characters/create/’, ChargenView.as_view(), name=’character-create’)

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can create new objects is the developer’s responsibility.

Returns:

path (str) – URI path to object creation page, if defined.

web_get_delete_url()[source]

Returns the URI path for a View that allows users to delete this object.

Returns:

path (str) – URI path to object deletion page, if defined.

Examples

Oscar (Character) = '/characters/oscar/1/delete/'

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-detail’ would be referenced by this method.

url(r'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/delete/$',
CharDeleteView.as_view(), name='character-delete')

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can delete this object is the developer’s responsibility.

web_get_detail_url()[source]

Returns the URI path for a View that allows users to view details for this object.

Returns:

path (str) – URI path to object detail page, if defined.

Examples

Oscar (Character) = '/characters/oscar/1/'

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-detail’ would be referenced by this method.

url(r'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/$',
    CharDetailView.as_view(), name='character-detail')

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can view this object is the developer’s responsibility.

web_get_puppet_url()[source]

Returns the URI path for a View that allows users to puppet a specific object.

Returns:

str – URI path to object puppet page, if defined.

Examples

Oscar (Character) = '/characters/oscar/1/puppet/'

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-puppet’ would be referenced by this method.

url(r'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/puppet/$',
    CharPuppetView.as_view(), name='character-puppet')

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can view this object is the developer’s responsibility.

web_get_update_url()[source]

Returns the URI path for a View that allows users to update this object.

Returns:

str – URI path to object update page, if defined.

Examples

Oscar (Character) = '/characters/oscar/1/change/'

For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘character-update’ would be referenced by this method.

url(r'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/change/$',
CharUpdateView.as_view(), name='character-update')

If no View has been created and defined in urls.py, returns an HTML anchor.

This method is naive and simply returns a path. Securing access to the actual view and limiting who can modify objects is the developer’s responsibility.

evennia.accounts.models.make_iter(obj)[source]

Makes sure that the object is always iterable.

Parameters:

obj (any) – Object to make iterable.

Returns:

iterable (list or iterable)

The same object

passed-through or made iterable.

evennia.accounts.models.smart_str(s, encoding='utf-8', strings_only=False, errors='strict')[source]

Return a string representing ‘s’. Treat bytestrings using the ‘encoding’ codec.

If strings_only is True, don’t convert (some) non-string-like objects.