mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 05:46:31 +01:00
300 lines
No EOL
21 KiB
HTML
300 lines
No EOL
21 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>evennia.web.admin.attributes — Evennia latest documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.web.admin.comms" href="evennia.web.admin.comms.html" />
|
||
<link rel="prev" title="evennia.web.admin.accounts" href="evennia.web.admin.accounts.html" />
|
||
</head><body>
|
||
|
||
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.web.admin.comms.html" title="evennia.web.admin.comms"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.web.admin.accounts.html" title="evennia.web.admin.accounts"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.web.html" >evennia.web</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.web.admin.html" accesskey="U">evennia.web.admin</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.web.admin.attributes</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
|
||
<div class="documentwrapper">
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.web.admin.accounts.html"
|
||
title="previous chapter">evennia.web.admin.accounts</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.web.admin.comms.html"
|
||
title="next chapter">evennia.web.admin.comms</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.web.admin.attributes.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li><a href="evennia.web.admin.attributes.html">latest (main branch)</a></li>
|
||
|
||
<li><a href="../../3.x/index.html">v3.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../2.x/index.html">v2.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../1.x/index.html">v1.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../0.x/index.html">v0.9.5 branch (outdated)</a></li>
|
||
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.web.admin.attributes">
|
||
<span id="evennia-web-admin-attributes"></span><h1>evennia.web.admin.attributes<a class="headerlink" href="#module-evennia.web.admin.attributes" title="Permalink to this headline">¶</a></h1>
|
||
<p>Attribute admin.</p>
|
||
<p>Note that we don’t present a separate admin for these, since they are only
|
||
relevant together with a specific object.</p>
|
||
<dl class="py class">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.web.admin.attributes.</code><code class="sig-name descname">AttributeForm</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeForm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">django.forms.models.ModelForm</span></code></p>
|
||
<p>This form overrides the base behavior of the ModelForm that would be used for a Attribute-through-model.
|
||
Since the through-models only have access to the foreignkeys of the Attribute and the Object that they’re
|
||
attached to, we need to spoof the behavior of it being a form that would correspond to its Attribute,
|
||
or the creation of an Attribute. Instead of being saved, we’ll call to the Object’s handler, which will handle
|
||
the creation, change, or deletion of an Attribute for us, as well as updating the handler’s cache so that all
|
||
changes are instantly updated in-game.</p>
|
||
<dl class="py class">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.Meta">
|
||
<em class="property">class </em><code class="sig-name descname">Meta</code><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeForm.Meta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.Meta" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.Meta.fields">
|
||
<code class="sig-name descname">fields</code><em class="property"> = ('attr_key', 'attr_value', 'attr_category', 'attr_lockstring', 'attr_type')</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.Meta.fields" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeForm.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>If we have an Attribute, then we’ll prepopulate our instance with the fields we’d expect it
|
||
to have based on the Attribute. attr_key, attr_category, attr_value, attr_type,
|
||
and attr_lockstring all refer to the corresponding Attribute fields. The initial data of the form fields will
|
||
similarly be populated.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.save">
|
||
<code class="sig-name descname">save</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">commit</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeForm.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.save" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>One thing we want to do here is the or None checks, because forms are saved with an empty
|
||
string rather than null from forms, usually, and the Handlers may handle empty strings
|
||
differently than None objects. So for consistency with how things are handled in game,
|
||
we’ll try to make sure that empty form fields will be None, rather than ‘’.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.clean_attr_value">
|
||
<code class="sig-name descname">clean_attr_value</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeForm.clean_attr_value"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.clean_attr_value" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Prevent certain data-types from being cleaned due to literal_eval
|
||
failing on them. Otherwise they will be turned into str.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.base_fields">
|
||
<code class="sig-name descname">base_fields</code><em class="property"> = {'attr_category': <django.forms.fields.CharField object>, 'attr_key': <django.forms.fields.CharField object>, 'attr_lockstring': <django.forms.fields.CharField object>, 'attr_type': <django.forms.fields.ChoiceField object>, 'attr_value': <evennia.utils.picklefield.PickledFormField object>}</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.base_fields" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.declared_fields">
|
||
<code class="sig-name descname">declared_fields</code><em class="property"> = {'attr_category': <django.forms.fields.CharField object>, 'attr_key': <django.forms.fields.CharField object>, 'attr_lockstring': <django.forms.fields.CharField object>, 'attr_type': <django.forms.fields.ChoiceField object>, 'attr_value': <evennia.utils.picklefield.PickledFormField object>}</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.declared_fields" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeForm.media">
|
||
<em class="property">property </em><code class="sig-name descname">media</code><a class="headerlink" href="#evennia.web.admin.attributes.AttributeForm.media" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return all media required to render the widgets on this form.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.web.admin.attributes.AttributeFormSet">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.web.admin.attributes.</code><code class="sig-name descname">AttributeFormSet</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">data</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">files</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">instance</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">save_as_new</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">prefix</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">queryset</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeFormSet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeFormSet" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">django.forms.models.BaseInlineFormSet</span></code></p>
|
||
<p>Attribute version of TagFormSet, as above.</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeFormSet.save">
|
||
<code class="sig-name descname">save</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">commit</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeFormSet.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeFormSet.save" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Save model instances for every form, adding and changing instances
|
||
as necessary, and return the list of instances.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.web.admin.attributes.</code><code class="sig-name descname">AttributeInline</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">parent_model</span></em>, <em class="sig-param"><span class="n">admin_site</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeInline"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">django.contrib.admin.options.TabularInline</span></code></p>
|
||
<p>A handler for inline Attributes. This class should be subclassed in the admin of your models,
|
||
and the ‘model’ and ‘related_field’ class attributes must be set. model should be the
|
||
through model (ObjectDB_db_tag’, for example), while related field should be the name
|
||
of the field on that through model which points to the model being used: ‘objectdb’,
|
||
‘msg’, ‘accountdb’, etc.</p>
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.model">
|
||
<code class="sig-name descname">model</code><em class="property"> = None</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.model" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.verbose_name">
|
||
<code class="sig-name descname">verbose_name</code><em class="property"> = 'Attribute'</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.verbose_name" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.verbose_name_plural">
|
||
<code class="sig-name descname">verbose_name_plural</code><em class="property"> = 'Attributes'</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.verbose_name_plural" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.form">
|
||
<code class="sig-name descname">form</code><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.form" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>alias of <a class="reference internal" href="#evennia.web.admin.attributes.AttributeForm" title="evennia.web.admin.attributes.AttributeForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">AttributeForm</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.formset">
|
||
<code class="sig-name descname">formset</code><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.formset" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>alias of <a class="reference internal" href="#evennia.web.admin.attributes.AttributeFormSet" title="evennia.web.admin.attributes.AttributeFormSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">AttributeFormSet</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.related_field">
|
||
<code class="sig-name descname">related_field</code><em class="property"> = None</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.related_field" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.extra">
|
||
<code class="sig-name descname">extra</code><em class="property"> = 0</em><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.extra" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.get_formset">
|
||
<code class="sig-name descname">get_formset</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">request</span></em>, <em class="sig-param"><span class="n">obj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/web/admin/attributes.html#AttributeInline.get_formset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.get_formset" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>get_formset has to return a class, but we need to make the class that we return
|
||
know about the related_field that we’ll use. Returning the class itself rather than
|
||
a proxy isn’t threadsafe, since it’d be the base class and would change if multiple
|
||
people used the admin at the same time</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.web.admin.attributes.AttributeInline.media">
|
||
<em class="property">property </em><code class="sig-name descname">media</code><a class="headerlink" href="#evennia.web.admin.attributes.AttributeInline.media" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.web.admin.comms.html" title="evennia.web.admin.comms"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.web.admin.accounts.html" title="evennia.web.admin.accounts"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.web.html" >evennia.web</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.web.admin.html" >evennia.web.admin</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.web.admin.attributes</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |