<spanid="evennia-contrib-base-systems-ingame-python-callbackhandler"></span><h1>evennia.contrib.base_systems.ingame_python.callbackhandler<aclass="headerlink"href="#module-evennia.contrib.base_systems.ingame_python.callbackhandler"title="Permalink to this headline">¶</a></h1>
<p>Module containing the CallbackHandler for individual objects.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.base_systems.ingame_python.callbackhandler.</code><codeclass="sig-name descname">CallbackHandler</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">obj</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">script</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.script"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">obj</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Return all callbacks linked to this object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>All callbacks in a dictionary callback_name</em>– callback}. The callback
is returned as a namedtuple to simplify manipulation.</p>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback_name</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the callbacks associated with this name.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>callback_name</strong> (<em>str</em>) – the name of the callback.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A list of callbacks associated with this object and of this name.</p>
</dd>
</dl>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>This method returns a list of callback objects (namedtuple
representations). If the callback name cannot be found in the
<codeclass="sig-name descname">get_variable</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">variable_name</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.get_variable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.get_variable"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the variable value or None.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>variable_name</strong> (<em>str</em>) – the name of the variable.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Either the variable’s value or None.</p>
<codeclass="sig-name descname">add</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback_name</span></em>, <emclass="sig-param"><spanclass="n">code</span></em>, <emclass="sig-param"><spanclass="n">author</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">valid</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">parameters</span><spanclass="o">=</span><spanclass="default_value">''</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.add"title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new callback for this object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback_name</strong> (<em>str</em>) – the name of the callback to add.</p></li>
<li><p><strong>code</strong> (<em>str</em>) – the Python code associated with this callback.</p></li>
<li><p><strong>author</strong> (<em>Character</em><em> or </em><em>Account</em><em>, </em><em>optional</em>) – the author of the callback.</p></li>
<li><p><strong>valid</strong> (<em>bool</em><em>, </em><em>optional</em>) – should the callback be connected?</p></li>
<codeclass="sig-name descname">edit</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback_name</span></em>, <emclass="sig-param"><spanclass="n">number</span></em>, <emclass="sig-param"><spanclass="n">code</span></em>, <emclass="sig-param"><spanclass="n">author</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">valid</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.edit"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.edit"title="Permalink to this definition">¶</a></dt>
<dd><p>Edit an existing callback bound to this object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback_name</strong> (<em>str</em>) – the name of the callback to edit.</p></li>
<li><p><strong>number</strong> (<em>int</em>) – the callback number to be changed.</p></li>
<li><p><strong>code</strong> (<em>str</em>) – the Python code associated with this callback.</p></li>
<li><p><strong>author</strong> (<em>Character</em><em> or </em><em>Account</em><em>, </em><em>optional</em>) – the author of the callback.</p></li>
<li><p><strong>valid</strong> (<em>bool</em><em>, </em><em>optional</em>) – should the callback be connected?</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The callback definition that was edited or None.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>RuntimeError if the callback is locked.</strong>–</p>
<codeclass="sig-name descname">remove</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback_name</span></em>, <emclass="sig-param"><spanclass="n">number</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.remove"title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the specified callback bound to this object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback_name</strong> (<em>str</em>) – the name of the callback to delete.</p></li>
<li><p><strong>number</strong> (<em>int</em>) – the number of the callback to delete.</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>RuntimeError if the callback is locked.</strong>–</p>
<codeclass="sig-name descname">call</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback_name</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.call"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.call"title="Permalink to this definition">¶</a></dt>
<dd><p>Call the specified callback(s) bound to this object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback_name</strong> (<em>str</em>) – the callback name to call.</p></li>
<li><p><strong>*args</strong>– additional variables for this callback.</p></li>
</ul>
</dd>
<dtclass="field-even">Keyword Arguments</dt>
<ddclass="field-even"><ulclass="simple">
<li><p><strong>number</strong> (<em>int</em><em>, </em><em>optional</em>) – call just a specific callback.</p></li>
<li><p><strong>parameters</strong> (<em>str</em><em>, </em><em>optional</em>) – call a callback with parameters.</p></li>
<li><p><strong>locals</strong> (<em>dict</em><em>, </em><em>optional</em>) – a locals replacement.</p></li>
</ul>
</dd>
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>True to report the callback was called without interruption,
False otherwise. If the callbackHandler isn’t found, return
<emclass="property">static </em><codeclass="sig-name descname">format_callback</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">callback</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/base_systems/ingame_python/callbackhandler.html#CallbackHandler.format_callback"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.CallbackHandler.format_callback"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the callback namedtuple to represent the specified callback.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>callback</strong> (<em>dict</em>) – the callback definition.</p>
</dd>
</dl>
<p>The callback given in argument should be a dictionary containing
the expected fields for a callback (code, author, valid…).</p>
<codeclass="sig-name descname">author</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.author"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">code</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.code"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">created_on</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.created_on"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">name</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.name"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">number</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.number"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">obj</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.obj"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">parameters</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.parameters"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">updated_by</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.updated_by"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">updated_on</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.updated_on"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">valid</code><aclass="headerlink"href="#evennia.contrib.base_systems.ingame_python.callbackhandler.Callback.valid"title="Permalink to this definition">¶</a></dt>