mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 13:26:30 +01:00
268 lines
No EOL
16 KiB
HTML
268 lines
No EOL
16 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.scripts.monitorhandler — Evennia 3.x 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.scripts.scripthandler" href="evennia.scripts.scripthandler.html" />
|
||
<link rel="prev" title="evennia.scripts.models" href="evennia.scripts.models.html" />
|
||
</head><body>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</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"
|
||
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.scripts.scripthandler.html" title="evennia.scripts.scripthandler"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.models.html" title="evennia.scripts.models"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 3.x</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.scripts.html" accesskey="U">evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.monitorhandler</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.scripts.models.html"
|
||
title="previous chapter">evennia.scripts.models</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.scripts.scripthandler.html"
|
||
title="next chapter">evennia.scripts.scripthandler</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.scripts.monitorhandler.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>
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.scripts.monitorhandler">
|
||
<span id="evennia-scripts-monitorhandler"></span><h1>evennia.scripts.monitorhandler<a class="headerlink" href="#module-evennia.scripts.monitorhandler" title="Permalink to this headline">¶</a></h1>
|
||
<p>Monitors - catch changes to model fields and Attributes.</p>
|
||
<p>The MONITOR_HANDLER singleton from this module offers the following
|
||
functionality:</p>
|
||
<ul class="simple">
|
||
<li><dl class="simple">
|
||
<dt>Field-monitor - track a object’s specific database field and perform</dt><dd><p>an action whenever that field <em>changes</em> for whatever reason.</p>
|
||
</dd>
|
||
</dl>
|
||
</li>
|
||
<li><dl class="simple">
|
||
<dt>Attribute-monitor tracks an object’s specific Attribute and perform</dt><dd><p>an action whenever that Attribute <em>changes</em> for whatever reason.</p>
|
||
</dd>
|
||
</dl>
|
||
</li>
|
||
</ul>
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.monitorhandler.</code><code class="sig-name descname">MonitorHandler</code><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler" 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>
|
||
<p>This is a resource singleton that allows for registering
|
||
callbacks for when a field or Attribute is updated (saved).</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Initialize the handler.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.save">
|
||
<code class="sig-name descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.save" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Store our monitors to the database. This is called
|
||
by the server process.</p>
|
||
<p>Since dbserialize can’t handle defaultdicts, we convert to an
|
||
intermediary save format ((obj,fieldname, idstring, callback, kwargs), …)</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.restore">
|
||
<code class="sig-name descname">restore</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">server_reload</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.restore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.restore" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Restore our monitors after a reload. This is called
|
||
by the server process.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>server_reload</strong> (<em>bool</em><em>, </em><em>optional</em>) – If this is False, it means
|
||
the server went through a cold reboot and all
|
||
non-persistent tickers must be killed.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.at_update">
|
||
<code class="sig-name descname">at_update</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em>, <em class="sig-param"><span class="n">fieldname</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.at_update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.at_update" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Called by the field/attribute as it saves.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em>, <em class="sig-param"><span class="n">fieldname</span></em>, <em class="sig-param"><span class="n">callback</span></em>, <em class="sig-param"><span class="n">idstring</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">persistent</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">category</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/scripts/monitorhandler.html#MonitorHandler.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Add monitoring to a given field or Attribute. A field must
|
||
be specified with the full db_* name or it will be assumed
|
||
to be an Attribute (so <strong>db_key</strong>, not just <strong>key</strong>).</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>obj</strong> (<em>Typeclassed Entity</em>) – The entity on which to monitor a
|
||
field or Attribute.</p></li>
|
||
<li><p><strong>fieldname</strong> (<em>str</em>) – Name of field (db_*) or Attribute to monitor.</p></li>
|
||
<li><p><strong>callback</strong> (<em>callable</em>) – A callable on the form <a href="#id1"><span class="problematic" id="id2">**</span></a>callable(<a href="#id3"><span class="problematic" id="id4">**</span></a>kwargs),
|
||
where kwargs holds keys fieldname and obj.</p></li>
|
||
<li><p><strong>idstring</strong> (<em>str</em><em>, </em><em>optional</em>) – An id to separate this monitor from other monitors
|
||
of the same field and object.</p></li>
|
||
<li><p><strong>persistent</strong> (<em>bool</em><em>, </em><em>optional</em>) – If False, the monitor will survive
|
||
a server reload but not a cold restart. This is default.</p></li>
|
||
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – This is only used if <strong>fieldname</strong> refers to
|
||
an Attribute (i.e. it does not start with <strong>db_</strong>). You must specify this
|
||
if you want to target an Attribute with a category.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments</dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>session</strong> (<a class="reference internal" href="evennia.server.session.html#evennia.server.session.Session" title="evennia.server.session.Session"><em>Session</em></a>) – If this keyword is given, the monitorhandler will
|
||
correctly analyze it and remove the monitor if after a reload/reboot
|
||
the session is no longer valid.</p></li>
|
||
<li><p><strong>any</strong> (<em>any</em>) – Any other kwargs are passed on to the callback. Remember that
|
||
all kwargs must be possible to pickle!</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.remove">
|
||
<code class="sig-name descname">remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em>, <em class="sig-param"><span class="n">fieldname</span></em>, <em class="sig-param"><span class="n">idstring</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.remove" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Remove a monitor.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.clear">
|
||
<code class="sig-name descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.clear" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Delete all monitors.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.monitorhandler.MonitorHandler.all">
|
||
<code class="sig-name descname">all</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/monitorhandler.html#MonitorHandler.all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.monitorhandler.MonitorHandler.all" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>List all monitors or all monitors of a given object.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>obj</strong> (<em>Object</em>) – The object on which to list all monitors.</p>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>monitors (list)</em> – The handled monitors.</p>
|
||
</dd>
|
||
</dl>
|
||
</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.scripts.scripthandler.html" title="evennia.scripts.scripthandler"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.models.html" title="evennia.scripts.models"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 3.x</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.scripts.html" >evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.monitorhandler</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</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> |