Commit 945e7cc0 authored by Thomas Mignot's avatar Thomas Mignot

maj docs with param

parent 5b0f4ff9
......@@ -38,9 +38,21 @@
<div class="viewcode-block" id="RyzomConfig"><a class="viewcode-back" href="../../ryzom.apps.html#ryzom.apps.RyzomConfig">[docs]</a><span class="k">class</span> <span class="nc">RyzomConfig</span><span class="p">(</span><span class="n">AppConfig</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Ryzom application configuration</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;ryzom&#39;</span>
<div class="viewcode-block" id="RyzomConfig.ready"><a class="viewcode-back" href="../../ryzom.apps.html#ryzom.apps.RyzomConfig.ready">[docs]</a> <span class="k">def</span> <span class="nf">ready</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> AppConfig.ready overloading.</span>
<span class="sd"> Here we import the ryzom.signals module to connect</span>
<span class="sd"> the signals handlers to receivers,</span>
<span class="sd"> then we clean the Clients table (zombies clients stay after</span>
<span class="sd"> a server reboot)</span>
<span class="sd"> Finally, we create the publications that were registered</span>
<span class="sd"> in the to_publish list of ryzom.pusub module.</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="kn">import</span> <span class="nn">ryzom.signals</span> <span class="c1"># noqa</span>
<span class="kn">from</span> <span class="nn">ryzom.pubsub</span> <span class="k">import</span> <span class="n">to_publish</span>
......
......@@ -49,6 +49,13 @@
<span class="sd"> to create a new instance of a component attached to a</span>
<span class="sd"> model that was inserted, updated or removed</span>
<span class="sd"> Essentially called by post_save and post_delete signal handlers</span>
<span class="sd"> :param Subscriptions sub: The Subscription holding the connection \</span>
<span class="sd"> information</span>
<span class="sd"> :param Publishable model: The class of the model to insert</span>
<span class="sd"> :param Component tmpl: The component subclass that templates \</span>
<span class="sd"> the model instance</span>
<span class="sd"> :param int _id: The id of the model to insert</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">tmpl_instance</span> <span class="o">=</span> <span class="n">tmpl</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">_id</span><span class="p">))</span>
<span class="n">tmpl_instance</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">sub</span><span class="o">.</span><span class="n">parent</span>
......@@ -73,6 +80,13 @@
<span class="sd"> to create a new instance of a component attached to a</span>
<span class="sd"> model that was updated</span>
<span class="sd"> Essentially called by post_save and post_delete signal handlers</span>
<span class="sd"> :param Subscriptions sub: The Subscription holding the connection \</span>
<span class="sd"> information</span>
<span class="sd"> :param Publishable model: The class of the model to change</span>
<span class="sd"> :param Component tmpl: The component subclass that templates \</span>
<span class="sd"> the model instance</span>
<span class="sd"> :param int _id: The id of the model to change</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">tmpl_instance</span> <span class="o">=</span> <span class="n">tmpl</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">_id</span><span class="p">))</span>
<span class="n">tmpl_instance</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">sub</span><span class="o">.</span><span class="n">parent</span>
......@@ -98,6 +112,13 @@
<span class="sd"> model that was removed, in order to get the computed _id</span>
<span class="sd"> and send the computed _id to the client.</span>
<span class="sd"> Essentially called by post_save and post_delete signal handlers</span>
<span class="sd"> :param Subscriptions sub: The Subscription holding the connection \</span>
<span class="sd"> information</span>
<span class="sd"> :param Publishable model: The class of the model to remove</span>
<span class="sd"> :param Component tmpl: The component subclass that templates \</span>
<span class="sd"> the model instance</span>
<span class="sd"> :param int _id: The id of the model to remove</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">tmp</span> <span class="o">=</span> <span class="n">model</span><span class="p">()</span>
<span class="n">tmp</span><span class="o">.</span><span class="n">id</span> <span class="o">=</span> <span class="n">_id</span>
......
......@@ -67,6 +67,20 @@
<span class="sd"> limit, ..etc, the set published.</span>
<span class="sd"> It defers the publication until the DB is ready to</span>
<span class="sd"> accept new entries.</span>
<span class="sd"> :param str name: A unique name</span>
<span class="sd"> :param str template: A Component module and class \</span>
<span class="sd"> `module.submodule.Class`</span>
<span class="sd"> :param list query: A list of dict of query parameters</span>
<span class="sd"> :examples:</span>
<span class="sd"> ::</span>
<span class="sd"> Tasks.publish(&#39;tasks&#39;, &#39;todos.components.tasks.Task&#39;, [</span>
<span class="sd"> {&#39;order_by&#39;: &#39;-about&#39;},</span>
<span class="sd"> {&#39;limit&#39;: 5},</span>
<span class="sd"> {&#39;offset&#39;: 3}</span>
<span class="sd"> ])</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_published</span><span class="p">:</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">_prepubs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">query</span><span class="p">)</span>
......@@ -83,6 +97,8 @@
<span class="sd"> if the publishable has already been published.</span>
<span class="sd"> If a publication of given name already exists,</span>
<span class="sd"> this method only updates its fields.</span>
<span class="sd"> :parameters: see :meth:`publish`</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">tmpl_cls</span><span class="p">,</span> <span class="n">tmpl_mod</span> <span class="o">=</span> <span class="n">template</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">tmpl_mod</span> <span class="o">=</span> <span class="n">tmpl_mod</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
......
......@@ -47,6 +47,9 @@
<span class="sd"> Subclass of component with reactive content.</span>
<span class="sd"> It takes a unique name and a ryzom.views.View in addition</span>
<span class="sd"> to common component parameters.</span>
<span class="sd"> :param str name: The (unique) name of the instance</span>
<span class="sd"> :param View view: The rizom View this instance is attached to</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">view</span><span class="p">,</span> <span class="n">tag</span><span class="o">=</span><span class="s1">&#39;div&#39;</span><span class="p">,</span> <span class="n">content</span><span class="o">=</span><span class="p">[],</span> <span class="n">attr</span><span class="o">=</span><span class="p">{},</span>
<span class="n">events</span><span class="o">=</span><span class="p">{},</span> <span class="n">parent</span><span class="o">=</span><span class="s1">&#39;body&#39;</span><span class="p">,</span> <span class="n">_id</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
......@@ -60,6 +63,9 @@
<span class="sd"> This method should be called only by the associated view</span>
<span class="sd"> to update the component contents, then it sends the new</span>
<span class="sd"> content to the client associated with the view instance</span>
<span class="sd"> :param list(Component) content: A list of Component to replace \</span>
<span class="sd"> the current content of the instance</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">content</span> <span class="o">=</span> <span class="n">content</span>
<span class="bp">self</span><span class="o">.</span><span class="n">preparecontent</span><span class="p">()</span>
......
......@@ -48,6 +48,9 @@
<span class="sd"> inheriting from this class.</span>
<span class="sd"> The methods oncreate() and ondestroy() can also be overloaded</span>
<span class="sd"> to run code on those events.</span>
<span class="sd"> :param str channel_name: The name of the channel this instance \</span>
<span class="sd"> is attached to</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">channel_name</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">channel_name</span> <span class="o">=</span> <span class="n">channel_name</span>
......@@ -58,6 +61,9 @@
<span class="sd"> Method intended to be used by reactive components.</span>
<span class="sd"> Registers a component to the reactive_components dict</span>
<span class="sd"> of the view instance.</span>
<span class="sd"> :param ReactiveComponent component: The reactive component to \</span>
<span class="sd"> attach to this View instance</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">reactive_components</span><span class="p">[</span><span class="n">component</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">component</span></div>
......@@ -65,6 +71,10 @@
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Method to update the content of a reactive component by name.</span>
<span class="sd"> the content parameter must be a subclass of ryzom.components.Component</span>
<span class="sd"> :param str name: The name of the \</span>
<span class="sd"> :class:`ryzom.reactive.ReactiveComponent` to update</span>
<span class="sd"> :param Component content: The new content</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">component</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reactive_components</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
<span class="n">component</span><span class="o">.</span><span class="n">setcontent</span><span class="p">(</span><span class="n">content</span><span class="p">)</span></div>
......@@ -77,16 +87,20 @@
<span class="sd"> controller.</span>
<span class="sd"> Its aim is to update the instance inheriting from this class</span>
<span class="sd"> on an geturl call.</span>
<span class="sd"> :param str url: The url the client is trying to access</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div>
<div class="viewcode-block" id="View.render"><a class="viewcode-back" href="../../ryzom.views.html#ryzom.views.View.render">[docs]</a> <span class="k">def</span> <span class="nf">render</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">url</span><span class="p">):</span>
<div class="viewcode-block" id="View.render"><a class="viewcode-back" href="../../ryzom.views.html#ryzom.views.View.render">[docs]</a> <span class="k">def</span> <span class="nf">render</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> To be overloaded.</span>
<span class="sd"> This method will be called whenever a websocket url is required</span>
<span class="sd"> and router to a new View controller.</span>
<span class="sd"> Its aim is to render a full content. After that, only reactive</span>
<span class="sd"> content should be updated by the onurl() method.</span>
<span class="sd"> :param str url: The url the client is trying to access</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div>
......@@ -96,10 +110,12 @@
<span class="sd"> This method will be called whenever a new instance of a View is</span>
<span class="sd"> created by the consumer.</span>
<span class="sd"> Its aim is to setup the view data, such as content, url or whatever.</span>
<span class="sd"> :param str url: The url the client is trying to access</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">pass</span></div>
<div class="viewcode-block" id="View.ondestroy"><a class="viewcode-back" href="../../ryzom.views.html#ryzom.views.View.ondestroy">[docs]</a> <span class="k">def</span> <span class="nf">ondestroy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">url</span><span class="p">):</span>
<div class="viewcode-block" id="View.ondestroy"><a class="viewcode-back" href="../../ryzom.views.html#ryzom.views.View.ondestroy">[docs]</a> <span class="k">def</span> <span class="nf">ondestroy</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Hook to optionaly overload.</span>
<span class="sd"> This method will be called whenever a instance of a View is</span>
......
......@@ -40,6 +40,7 @@
<dt id="ryzom.apps.RyzomConfig">
<em class="property">class </em><code class="descclassname">ryzom.apps.</code><code class="descname">RyzomConfig</code><span class="sig-paren">(</span><em>app_name</em>, <em>app_module</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/apps.html#RyzomConfig"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.apps.RyzomConfig" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">django.apps.config.AppConfig</span></code></p>
<p>Ryzom application configuration</p>
<dl class="attribute">
<dt id="ryzom.apps.RyzomConfig.name">
<code class="descname">name</code><em class="property"> = 'ryzom'</em><a class="headerlink" href="#ryzom.apps.RyzomConfig.name" title="Permalink to this definition"></a></dt>
......@@ -48,7 +49,13 @@
<dl class="method">
<dt id="ryzom.apps.RyzomConfig.ready">
<code class="descname">ready</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/apps.html#RyzomConfig.ready"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.apps.RyzomConfig.ready" title="Permalink to this definition"></a></dt>
<dd><p>Override this method in subclasses to run code when Django starts.</p>
<dd><p>AppConfig.ready overloading.
Here we import the ryzom.signals module to connect
the signals handlers to receivers,
then we clean the Clients table (zombies clients stay after
a server reboot)
Finally, we create the publications that were registered
in the to_publish list of ryzom.pusub module.</p>
</dd></dl>
</dd></dl>
......
......@@ -47,6 +47,20 @@ Uses the template class associated with a publication
to create a new instance of a component attached to a
model that was updated
Essentially called by post_save and post_delete signal handlers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>sub</strong> (<a class="reference internal" href="ryzom.models.html#ryzom.models.Subscriptions" title="ryzom.models.Subscriptions"><em>Subscriptions</em></a>) – The Subscription holding the connection information</li>
<li><strong>model</strong> (<a class="reference internal" href="ryzom.pubsub.html#ryzom.pubsub.Publishable" title="ryzom.pubsub.Publishable"><em>Publishable</em></a>) – The class of the model to change</li>
<li><strong>tmpl</strong> (<a class="reference internal" href="ryzom.components.html#ryzom.components.Component" title="ryzom.components.Component"><em>Component</em></a>) – The component subclass that templates the model instance</li>
<li><strong>_id</strong> (<em>int</em>) – The id of the model to change</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
......@@ -59,6 +73,20 @@ Uses the template class associated with a publication
to create a new instance of a component attached to a
model that was inserted, updated or removed
Essentially called by post_save and post_delete signal handlers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>sub</strong> (<a class="reference internal" href="ryzom.models.html#ryzom.models.Subscriptions" title="ryzom.models.Subscriptions"><em>Subscriptions</em></a>) – The Subscription holding the connection information</li>
<li><strong>model</strong> (<a class="reference internal" href="ryzom.pubsub.html#ryzom.pubsub.Publishable" title="ryzom.pubsub.Publishable"><em>Publishable</em></a>) – The class of the model to insert</li>
<li><strong>tmpl</strong> (<a class="reference internal" href="ryzom.components.html#ryzom.components.Component" title="ryzom.components.Component"><em>Component</em></a>) – The component subclass that templates the model instance</li>
<li><strong>_id</strong> (<em>int</em>) – The id of the model to insert</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
......@@ -72,6 +100,20 @@ to create a new instance of a component attached to a
model that was removed, in order to get the computed _id
and send the computed _id to the client.
Essentially called by post_save and post_delete signal handlers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>sub</strong> (<a class="reference internal" href="ryzom.models.html#ryzom.models.Subscriptions" title="ryzom.models.Subscriptions"><em>Subscriptions</em></a>) – The Subscription holding the connection information</li>
<li><strong>model</strong> (<a class="reference internal" href="ryzom.pubsub.html#ryzom.pubsub.Publishable" title="ryzom.pubsub.Publishable"><em>Publishable</em></a>) – The class of the model to remove</li>
<li><strong>tmpl</strong> (<a class="reference internal" href="ryzom.components.html#ryzom.components.Component" title="ryzom.components.Component"><em>Component</em></a>) – The component subclass that templates the model instance</li>
<li><strong>_id</strong> (<em>int</em>) – The id of the model to remove</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
......
......@@ -56,6 +56,11 @@
</div>
<div class="section" id="module-ryzom">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-ryzom" title="Permalink to this headline"></a></h2>
<p>Ryzom is a reactive fullstack python framework made on the top
of the Django framework.
Ryzom is highly inspired by the open source software MeteorJS,
if you like JavaScript and don’t know it, please, give it a try!</p>
<p>Ryzom will always stay open source.</p>
</div>
</div>
......
......@@ -54,6 +54,14 @@ called by the publish_all() method, or by publish()
if the publishable has already been published.
If a publication of given name already exists,
this method only updates its fields.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body">see <a class="reference internal" href="#ryzom.pubsub.Publishable.publish" title="ryzom.pubsub.Publishable.publish"><code class="xref py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="classmethod">
......@@ -66,6 +74,28 @@ this class, and the query that will filter, order,
limit, ..etc, the set published.
It defers the publication until the DB is ready to
accept new entries.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>name</strong> (<em>str</em>) – A unique name</li>
<li><strong>template</strong> (<em>str</em>) – A Component module and class <cite>module.submodule.Class</cite></li>
<li><strong>query</strong> (<em>list</em>) – A list of dict of query parameters</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Examples:</th><td class="field-body"><div class="first last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tasks</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="s1">&#39;tasks&#39;</span><span class="p">,</span> <span class="s1">&#39;todos.components.tasks.Task&#39;</span><span class="p">,</span> <span class="p">[</span>
<span class="p">{</span><span class="s1">&#39;order_by&#39;</span><span class="p">:</span> <span class="s1">&#39;-about&#39;</span><span class="p">},</span>
<span class="p">{</span><span class="s1">&#39;limit&#39;</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span>
<span class="p">{</span><span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">}</span>
<span class="p">])</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="classmethod">
......@@ -80,7 +110,7 @@ associated to the current model class.</p>
<dl class="data">
<dt id="ryzom.pubsub.to_publish">
<code class="descclassname">ryzom.pubsub.</code><code class="descname">to_publish</code><em class="property"> = []</em><a class="headerlink" href="#ryzom.pubsub.to_publish" title="Permalink to this definition"></a></dt>
<code class="descclassname">ryzom.pubsub.</code><code class="descname">to_publish</code><em class="property"> = [&lt;class 'todos.models.Tasks'&gt;]</em><a class="headerlink" href="#ryzom.pubsub.to_publish" title="Permalink to this definition"></a></dt>
<dd><p>This variable is intented to be used only in the ryzom.apps
AppConfig.ready() to populate the DB with publications
at server startup.</p>
......
......@@ -45,12 +45,32 @@ to create reactive content</p>
<p>Subclass of component with reactive content.
It takes a unique name and a ryzom.views.View in addition
to common component parameters.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> (<em>str</em>) – The (unique) name of the instance</li>
<li><strong>view</strong> (<a class="reference internal" href="ryzom.views.html#ryzom.views.View" title="ryzom.views.View"><em>View</em></a>) – The rizom View this instance is attached to</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="ryzom.reactive.ReactiveComponent.setcontent">
<code class="descname">setcontent</code><span class="sig-paren">(</span><em>content</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/reactive.html#ReactiveComponent.setcontent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.reactive.ReactiveComponent.setcontent" title="Permalink to this definition"></a></dt>
<dd><p>This method should be called only by the associated view
to update the component contents, then it sends the new
content to the client associated with the view instance</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>content</strong> (<em>list</em><em>(</em><a class="reference internal" href="ryzom.components.html#ryzom.components.Component" title="ryzom.components.Component"><em>Component</em></a><em>)</em>) – A list of Component to replace the current content of the instance</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
......
......@@ -47,12 +47,28 @@ It is necessary to overload the methods onurl and render when
inheriting from this class.
The methods oncreate() and ondestroy() can also be overloaded
to run code on those events.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel_name</strong> (<em>str</em>) – The name of the channel this instance is attached to</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="ryzom.views.View.addReactiveComponent">
<code class="descname">addReactiveComponent</code><span class="sig-paren">(</span><em>component</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.addReactiveComponent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.addReactiveComponent" title="Permalink to this definition"></a></dt>
<dd><p>Method intended to be used by reactive components.
Registers a component to the reactive_components dict
of the view instance.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>component</strong> (<a class="reference internal" href="ryzom.reactive.html#ryzom.reactive.ReactiveComponent" title="ryzom.reactive.ReactiveComponent"><em>ReactiveComponent</em></a>) – The reactive component to attach to this View instance</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
......@@ -62,11 +78,19 @@ of the view instance.</p>
This method will be called whenever a new instance of a View is
created by the consumer.
Its aim is to setup the view data, such as content, url or whatever.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>url</strong> (<em>str</em>) – The url the client is trying to access</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="ryzom.views.View.ondestroy">
<code class="descname">ondestroy</code><span class="sig-paren">(</span><em>url</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.ondestroy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.ondestroy" title="Permalink to this definition"></a></dt>
<code class="descname">ondestroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.ondestroy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.ondestroy" title="Permalink to this definition"></a></dt>
<dd><p>Hook to optionaly overload.
This method will be called whenever a instance of a View is
destroyed by the consumer.</p>
......@@ -81,6 +105,14 @@ This method will be called whenever a websocket url is required
controller.
Its aim is to update the instance inheriting from this class
on an geturl call.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>url</strong> (<em>str</em>) – The url the client is trying to access</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
......@@ -88,16 +120,36 @@ on an geturl call.</p>
<code class="descname">reactive</code><span class="sig-paren">(</span><em>name</em>, <em>content</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.reactive"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.reactive" title="Permalink to this definition"></a></dt>
<dd><p>Method to update the content of a reactive component by name.
the content parameter must be a subclass of ryzom.components.Component</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> (<em>str</em>) – The name of the <a class="reference internal" href="ryzom.reactive.html#ryzom.reactive.ReactiveComponent" title="ryzom.reactive.ReactiveComponent"><code class="xref py py-class docutils literal notranslate"><span class="pre">ryzom.reactive.ReactiveComponent</span></code></a> to update</li>
<li><strong>content</strong> (<a class="reference internal" href="ryzom.components.html#ryzom.components.Component" title="ryzom.components.Component"><em>Component</em></a>) – The new content</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="ryzom.views.View.render">
<code class="descname">render</code><span class="sig-paren">(</span><em>url</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.render"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.render" title="Permalink to this definition"></a></dt>
<code class="descname">render</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/ryzom/views.html#View.render"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ryzom.views.View.render" title="Permalink to this definition"></a></dt>
<dd><p>To be overloaded.
This method will be called whenever a websocket url is required
and router to a new View controller.
Its aim is to render a full content. After that, only reactive
content should be updated by the onurl() method.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>url</strong> (<em>str</em>) – The url the client is trying to access</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
......
This diff is collapsed.
'''
Ryzom is a reactive fullstack python framework made on the top
of the Django framework.
Ryzom is highly inspired by the open source software MeteorJS,
if you like JavaScript and don't know it, please, give it a try!
Ryzom will always stay open source.
'''
default_app_config = 'ryzom.apps.RyzomConfig'
......@@ -3,9 +3,21 @@ from django.db import OperationalError, ProgrammingError
class RyzomConfig(AppConfig):
'''
Ryzom application configuration
'''
name = 'ryzom'
def ready(self):
'''
AppConfig.ready overloading.
Here we import the ryzom.signals module to connect
the signals handlers to receivers,
then we clean the Clients table (zombies clients stay after
a server reboot)
Finally, we create the publications that were registered
in the to_publish list of ryzom.pusub module.
'''
import ryzom.signals # noqa
from ryzom.pubsub import to_publish
......
'''
Ryzom components declarations.
There's still a lot of tags missing.
They will be added when they'll be required
They will be added when they'll be needed
'''
import jsonpickle
import uuid
class Component():
'''
Main ryzom component 'abstract' class to be inherited.
'''Main ryzom component 'abstract' class to be inherited.
This class defines the common attributes and methods to all
components,the main one being to_obj() that format an instance
as a serializable dict that can be sent to the client over websocket
......@@ -22,6 +22,16 @@ class Component():
Being a childnode of <body> seem a lot more meaningfull.
If no _id is precised, a random (but still unique) one will be
generated.
:param str tag: The HTML tag of the component
:param list<Component> content: The component instances contained \
by the current instance
:param dict attr: HTML attributes (id, class, style, ...)
:param dict events: The events to add listeners to \
(click, hover, ...)
:param str parent: The id of the component that contains the \
current instance
:param str _id: The _id of the current instance (must be unique)
'''
def __init__(self,
tag='div',
......@@ -41,7 +51,8 @@ class Component():
self.preparecontent()
def preparecontent(self):
'''
'''Set the parent and position of children
meant to be called by __init__().
This method sets the current component as parent of each child
Moreover it sets the child's position attribute to its index
......@@ -56,43 +67,61 @@ class Component():
self.content = [Text(self.content)]
def addchild(self, component):
'''
'''Add a child component
Currently not used at all, but meant to push a new child
at the end of the content's list
A call to preparecontent() should follow the call to this method
:param Component component: The child component to add to the \
content of the current instance
'''
component.position = len(self.content)
component.parent = self._id
self.content.append(component)
def addchildren(self, components):
'''
'''Add a list of children
Currently not used at all, meant to push children at the
end of the content's list
end of the content's list.
A call to preparecontent() should follow the call to this method
:param list(Component) components: The component list to insert \
in the content of the current instance
'''
for component in components:
self.addchild(component)
def addevents(self, events):
'''
'''Add events to instance
Currently not used, meant to add/update a dict of eventListener
attached to the DOM element associated with this instance
:param dict events: The dict to update events with
'''
self.events.update(events)
def to_json(self):
'''
No more used, subject to deletion
:returns: A serialized JSON representation of the instance
'''
return jsonpickle.encode(self)
def to_obj(self):
'''
'''Get a serializable dict of the instance
This methods returns a dict representation of the current
instance. I handles subscriptions that will have this component
instance _id as parent attribute.
Recursively sets the content as dict too (maybe recursiveness is not
a good thing to do without any control of how deep can the tree be,
there's a risk of stack overflow that we must keep in mind)
:returns: A serializable representation of the instance
'''
return {
'_id': self._id,
......@@ -110,66 +139,143 @@ class Component():
class Div(Component):
'''
Div component
Represents a <div> HTML tag
:parameters: see :class:`Component`
'''
def __init__(self, content=[], attr={}, events={},
parent='body', _id=None):
super().__init__('div', content, attr, events, parent, _id)
class Ul(Component):
'''
Ul component