docs/build/html/site.html
changeset 78 54aeb42c0d80
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/build/html/site.html	Tue Nov 22 21:35:46 2016 +0100
@@ -0,0 +1,179 @@
+<!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>PyAMS site management &#8212; PyAMS_utils 0.1.4 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.4',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </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="top" title="PyAMS_utils 0.1.4 documentation" href="index.html" />
+    <link rel="next" title="PyAMS namespace traverser" href="traverser.html" />
+    <link rel="prev" title="Managing ZCA with PyAMS" href="zca.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 role="document">
+
+    <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="traverser.html" title="PyAMS namespace traverser"
+             accesskey="N">next</a> |</li>
+        <li class="right" >
+          <a href="zca.html" title="Managing ZCA with PyAMS"
+             accesskey="P">previous</a> |</li>
+        <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> &#187;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body" role="main">
+            
+  <div class="section" id="pyams-site-management">
+<span id="site"></span><h1>PyAMS site management<a class="headerlink" href="#pyams-site-management" title="Permalink to this headline">¶</a></h1>
+<p>PyAMS site management is based on the ZODB.</p>
+<p>On application startup, if PyAMS_utils package is included into Pyramid configuration, several operations take
+place:</p>
+<blockquote>
+<div><ul class="simple">
+<li>a custom <strong>site factory</strong> is defined</li>
+<li>custom request methods are defined</li>
+<li>a custom <strong>traverser</strong> handling <strong>namespaces</strong> is defined</li>
+<li>a custom subscribers predicate based on interfaces support is defined</li>
+<li>several adapters are registered, to handle annotations and key references</li>
+<li>custom TALES extensions are registered.</li>
+</ul>
+</div></blockquote>
+<p>The site factory is an important component in this process. It is this factory which will define the application root
+and create a <strong>local site manager</strong>.</p>
+<p>Pyramid application is loaded from ZODB&#8217;s root via a key defined in Pyramid&#8217;s configuration file; the key is named
+<em>pyams.application_name</em> and it&#8217;s default value is <em>application</em>.</p>
+<p>If the application can&#8217;t be found, PyAMS is looking for an application class name in Pyramid&#8217;s configuration file; the
+class name configuration key is called <em>pyams.application_factory</em> and defined by default as
+<em>pyams_utils.site.BaseSiteRoot</em>. PyAMS default site factory will then create the application, and add a local site
+manager to it (see <a class="reference internal" href="zca.html#zca"><span class="std std-ref">Managing ZCA with PyAMS</span></a>).</p>
+<p>After application creation, a <a class="reference internal" href="pyams_utils.html#pyams_utils.site.NewLocalSiteCreatedEvent" title="pyams_utils.site.NewLocalSiteCreatedEvent"><code class="xref py py-class docutils literal"><span class="pre">NewLocalSiteCreatedEvent</span></code></a> is
+notified. Custom packages can subscribe to this event to register custom components.</p>
+<div class="section" id="pyams-upgrade-command-line-script">
+<h2><em>pyams_upgrade</em> command line script<a class="headerlink" href="#pyams-upgrade-command-line-script" title="Permalink to this headline">¶</a></h2>
+<p>Pyramid allows to define custom command line scripts for application management. A script called <em>pyams_upgrade</em> is
+provided by PyAMS_utils package;&nbsp;this script apply the same process as PyAMS site factory, but can also be used to
+manage <strong>database generations</strong>. The idea behind this is just to allow custom packages to provide a way to check and
+upgrade database configuration away from application startup process:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="c"># ./bin/pyams_upgrade webapp/development.ini</span>
+</pre></div>
+</div>
+<p>A <strong>site generation checker</strong> is just a named utility providing <code class="xref py py-class docutils literal"><span class="pre">pyams_utils.interfaces.site.ISiteGenerations</span></code>
+interface. For example, <strong>pyams_security</strong> package provides such utility, to make sure that local site manager
+contains a PyAMS security manager and a principal annotation utility:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_utils.site</span> <span class="kn">import</span> <span class="n">check_required_utilities</span>
+
+<span class="n">REQUIRED_UTILITIES</span> <span class="o">=</span> <span class="p">((</span><span class="n">ISecurityManager</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">,</span> <span class="n">SecurityManager</span><span class="p">,</span> <span class="s">&#39;Security manager&#39;</span><span class="p">),</span>
+                      <span class="p">(</span><span class="n">IPrincipalAnnotationUtility</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">,</span> <span class="n">PrincipalAnnotationUtility</span><span class="p">,</span> <span class="s">&#39;User profiles&#39;</span><span class="p">))</span>
+
+<span class="nd">@utility_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;PyAMS security&#39;</span><span class="p">,</span> <span class="n">provides</span><span class="o">=</span><span class="n">ISiteGenerations</span><span class="p">)</span>
+<span class="k">class</span> <span class="nc">SecurityGenerationsChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<span class="sd">&quot;&quot;&quot;I18n generations checker&quot;&quot;&quot;</span>
+
+    <span class="n">generation</span> <span class="o">=</span> <span class="mi">1</span>
+
+    <span class="k">def</span> <span class="nf">evolve</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">site</span><span class="p">,</span> <span class="n">current</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Check for required utilities&quot;&quot;&quot;</span>
+        <span class="n">check_required_utilities</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="n">REQUIRED_UTILITIES</span><span class="p">)</span>
+</pre></div>
+</div>
+<p><a class="reference internal" href="pyams_utils.html#pyams_utils.site.check_required_utilities" title="pyams_utils.site.check_required_utilities"><code class="xref py py-func docutils literal"><span class="pre">check_required_utilities</span></code></a> is a PyAMS_utils utility function which
+can to used to verify that a set of local utilities are correctly registered with the given names and interfaces.</p>
+</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="#">PyAMS site management</a><ul>
+<li><a class="reference internal" href="#pyams-upgrade-command-line-script"><em>pyams_upgrade</em> command line script</a></li>
+</ul>
+</li>
+</ul>
+
+  <h4>Previous topic</h4>
+  <p class="topless"><a href="zca.html"
+                        title="previous chapter">Managing ZCA with PyAMS</a></p>
+  <h4>Next topic</h4>
+  <p class="topless"><a href="traverser.html"
+                        title="next chapter">PyAMS namespace traverser</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="py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li class="right" >
+          <a href="traverser.html" title="PyAMS namespace traverser"
+             >next</a> |</li>
+        <li class="right" >
+          <a href="zca.html" title="Managing ZCA with PyAMS"
+             >previous</a> |</li>
+        <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> &#187;</li> 
+      </ul>
+    </div>
+    <div class="footer" role="contentinfo">
+        &#169; Copyright 2016, Thierry Florac &lt;tflorac@ulthar.net&gt;.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
+    </div>
+  </body>
+</html>
\ No newline at end of file