evennia.web.website.forms

class evennia.web.website.forms.EvenniaForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

This is a stock Django form, but modified so that all values provided through it are escaped (sanitized). Validation is performed by the fields you define in the form.

This has little to do with Evennia itself and is more general web security- related.

https://www.owasp.org/index.php/Input_Validation_Cheat_Sheet#Goals_of_Input_Validation

clean()[source]

Django hook. Performed on form submission.

Returns

cleaned (dict) – Dictionary of key:value pairs submitted on the form.

base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class evennia.web.website.forms.AccountForm(*args, **kwargs)[source]

Bases: django.contrib.auth.forms.UserCreationForm

This is a generic Django form tailored to the Account model.

In this incarnation it does not allow getting/setting of attributes, only core User model fields (username, email, password).

class Meta[source]

Bases: object

This is a Django construct that provides additional configuration to the form.

model

alias of typeclasses.accounts.Account

fields = ('username', 'email')
field_classes = {'username': <class 'django.contrib.auth.forms.UsernameField'>}
base_fields = {'email': <django.forms.fields.EmailField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'username': <django.contrib.auth.forms.UsernameField object>}
declared_fields = {'email': <django.forms.fields.EmailField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class evennia.web.website.forms.ObjectForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: evennia.web.website.forms.EvenniaForm, django.forms.models.ModelForm

This is a Django form for generic Evennia Objects that allows modification of attributes when called from a descendent of ObjectUpdate or ObjectCreate views.

It defines no fields by default; you have to do that by extending this class and defining what fields you want to be recorded. See the CharacterForm for a simple example of how to do this.

class Meta[source]

Bases: object

This is a Django construct that provides additional configuration to the form.

model

alias of typeclasses.objects.Object

fields = ('db_key',)
labels = {'db_key': 'Name'}
base_fields = {'db_key': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class evennia.web.website.forms.CharacterForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: evennia.web.website.forms.ObjectForm

This is a Django form for Evennia Character objects.

Since Evennia characters only have one attribute by default, this form only defines a field for that single attribute. The names of fields you define should correspond to their names as stored in the dbhandler; you can display ‘prettier’ versions of the fieldname on the form using the ‘label’ kwarg.

The basic field types are CharFields and IntegerFields, which let you enter text and numbers respectively. IntegerFields have some neat validation tricks they can do, like mandating values fall within a certain range.

For example, a complete “age” field (which stores its value to character.db.age might look like:

age = forms.IntegerField(

label=”Your Age”, min_value=18, max_value=9000, help_text=”Years since your birth.”)

Default input fields are generic single-line text boxes. You can control what sort of input field users will see by specifying a “widget.” An example of this is used for the ‘desc’ field to show a Textarea box instead of a Textbox.

For help in building out your form, please see: https://docs.djangoproject.com/en/1.11/topics/forms/#building-a-form-in-django

For more information on fields and their capabilities, see: https://docs.djangoproject.com/en/1.11/ref/forms/fields/

For more on widgets, see: https://docs.djangoproject.com/en/1.11/ref/forms/widgets/

class Meta[source]

Bases: object

This is a Django construct that provides additional configuration to the form.

model

alias of typeclasses.characters.Character

fields = ('db_key',)
labels = {'db_key': 'Name'}
base_fields = {'db_key': <django.forms.fields.CharField object>, 'desc': <django.forms.fields.CharField object>}
declared_fields = {'desc': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class evennia.web.website.forms.CharacterUpdateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: evennia.web.website.forms.CharacterForm

This is a Django form for updating Evennia Character objects.

By default it is the same as the CharacterForm, but if there are circumstances in which you don’t want to let players edit all the same attributes they had access to during creation, you can redefine this form with those fields you do wish to allow.

base_fields = {'db_key': <django.forms.fields.CharField object>, 'desc': <django.forms.fields.CharField object>}
declared_fields = {'desc': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.