src/build/html/utilities.html
changeset 0 d153941bb745
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/build/html/utilities.html	Sun Jan 14 11:48:51 2018 +0100
@@ -0,0 +1,145 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <title>Custom PyAMS utilities &#8212; PyAMS User Guide 0.1.0 documentation</title>
+    <link rel="stylesheet" href="_static/pyramid.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '0.1.0',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true,
+        SOURCELINK_SUFFIX: '.txt'
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <link rel="index" title="Index" href="genindex.html" />
+    <link rel="search" title="Search" href="search.html" />
+    <link rel="prev" title="Custom TALES extensions" href="tales.html" />
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Neuton&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nobile:regular,italic,bold,bolditalic&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
+<!--[if lte IE 6]>
+<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
+<![endif]-->
+
+  </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="tales.html" title="Custom TALES extensions"
+             accesskey="P">previous</a> |</li>
+        <li class="nav-item nav-item-0"><a href="index.html">PyAMS User Guide 0.1.0 documentation</a> &#187;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body" role="main">
+            
+  <div class="section" id="custom-pyams-utilities">
+<span id="utilities"></span><h1>Custom PyAMS utilities<a class="headerlink" href="#custom-pyams-utilities" title="Permalink to this headline">¶</a></h1>
+<p>PyAMS_utils provides a small set of utilities. You can create some of them as global utilities registered in
+the global components registry; other ones can be created manually by a site administrator and
+are then registered automatically.</p>
+<div class="section" id="server-timezone">
+<h2>Server timezone<a class="headerlink" href="#server-timezone" title="Permalink to this headline">¶</a></h2>
+<p>To manage timezones correctly, and display datetimes based on current server timezone, all datetimes should
+be defined and stored in UTC.</p>
+<p>PyAMS_utils provides a <code class="xref py py-class docutils literal"><span class="pre">ServerTimezoneUtility</span></code> which
+allows you to assign a default timezone to your server.</p>
+<p>To display a datetime with correct timezone, you can use the <code class="xref py py-func docutils literal"><span class="pre">tztime</span></code> function,
+which assign server timezone to the given parameter:</p>
+<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
+<span class="kn">from</span> <span class="nn">pyams_utils.timezone</span> <span class="kn">import</span> <span class="n">tztime</span>
+
+<span class="n">now</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">()</span>
+<span class="n">my_date</span> <span class="o">=</span> <span class="n">tztime</span><span class="p">(</span><span class="n">now</span><span class="p">)</span>  <span class="c1"># converts *now* to server timezone</span>
+</pre></div>
+</div>
+<p>We could imagine that datetimes could be displayed with current user timezone. But it’s quite impossible to know
+the user timazone from a server request. The only options are:</p>
+<ul class="simple">
+<li>you ask an authenticated user to update a timezone setting in his profile</li>
+<li>you can include Javascript libraries which will try to detect browser timezone from their computer configuration, and
+do an AJAX request to update data in their session.</li>
+</ul>
+<p>That should require an update of <code class="xref py py-func docutils literal"><span class="pre">tzinfo()</span></code> adapter to get timezone info from session, request or user profile.</p>
+</div>
+<div class="section" id="zeo-connection">
+<h2>ZEO connection<a class="headerlink" href="#zeo-connection" title="Permalink to this headline">¶</a></h2>
+<p>Several PyAMS utilities (like the tasks scheduler or the medias converter) are working with dedicated processes,
+are connected to main PyAMS process through ØMQ, and use ZEO connections for their PyAMS database access.</p>
+<p>Clients of these processes have to send settings of the ZEO connections that they should use.</p>
+<p>The ZEOConnection utility can be created by the site manager through the web management interface (ZMI) from the
+<em>Control panel</em>:</p>
+<img alt="_images/zeo-add-menu.png" src="_images/zeo-add-menu.png" />
+<p>ZEO connection creation form allows you to define all settings of a ZEO connection:</p>
+<img alt="_images/zeo-add-form.png" src="_images/zeo-add-form.png" />
+</div>
+</div>
+
+
+          </div>
+        </div>
+      </div>
+      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
+        <div class="sphinxsidebarwrapper">
+  <h3><a href="index.html">Table Of Contents</a></h3>
+  <ul>
+<li><a class="reference internal" href="#">Custom PyAMS utilities</a><ul>
+<li><a class="reference internal" href="#server-timezone">Server timezone</a></li>
+<li><a class="reference internal" href="#zeo-connection">ZEO connection</a></li>
+</ul>
+</li>
+</ul>
+
+  <h4>Previous topic</h4>
+  <p class="topless"><a href="tales.html"
+                        title="previous chapter">Custom TALES extensions</a></p>
+<div id="searchbox" style="display: none" role="search">
+  <h3>Quick search</h3>
+    <form class="search" action="search.html" method="get">
+      <div><input type="text" name="q" /></div>
+      <div><input type="submit" value="Go" /></div>
+      <input type="hidden" name="check_keywords" value="yes" />
+      <input type="hidden" name="area" value="default" />
+    </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+        </div>
+      </div>
+      <div class="clearer"></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="tales.html" title="Custom TALES extensions"
+             >previous</a> |</li>
+        <li class="nav-item nav-item-0"><a href="index.html">PyAMS User Guide 0.1.0 documentation</a> &#187;</li> 
+      </ul>
+    </div>
+    <div class="footer" role="contentinfo">
+        &#169; Copyright 2017, Thierry Florac.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.5.
+    </div>
+  </body>
+</html>
\ No newline at end of file