1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
|
4 |
|
5 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
6 <head> |
|
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
8 |
|
9 <title>PyAMS site management — PyAMS_utils 0.1.4 documentation</title> |
|
10 |
|
11 <link rel="stylesheet" href="_static/pyramid.css" type="text/css" /> |
|
12 <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> |
|
13 |
|
14 <script type="text/javascript"> |
|
15 var DOCUMENTATION_OPTIONS = { |
|
16 URL_ROOT: './', |
|
17 VERSION: '0.1.4', |
|
18 COLLAPSE_INDEX: false, |
|
19 FILE_SUFFIX: '.html', |
|
20 HAS_SOURCE: true |
|
21 }; |
|
22 </script> |
|
23 <script type="text/javascript" src="_static/jquery.js"></script> |
|
24 <script type="text/javascript" src="_static/underscore.js"></script> |
|
25 <script type="text/javascript" src="_static/doctools.js"></script> |
|
26 <link rel="index" title="Index" href="genindex.html" /> |
|
27 <link rel="search" title="Search" href="search.html" /> |
|
28 <link rel="top" title="PyAMS_utils 0.1.4 documentation" href="index.html" /> |
|
29 <link rel="next" title="PyAMS namespace traverser" href="traverser.html" /> |
|
30 <link rel="prev" title="Managing ZCA with PyAMS" href="zca.html" /> |
|
31 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Neuton&subset=latin" type="text/css" media="screen" charset="utf-8" /> |
|
32 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nobile:regular,italic,bold,bolditalic&subset=latin" type="text/css" media="screen" charset="utf-8" /> |
|
33 <!--[if lte IE 6]> |
|
34 <link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" /> |
|
35 <![endif]--> |
|
36 |
|
37 </head> |
|
38 <body role="document"> |
|
39 |
|
40 <div class="related" role="navigation" aria-label="related navigation"> |
|
41 <h3>Navigation</h3> |
|
42 <ul> |
|
43 <li class="right" style="margin-right: 10px"> |
|
44 <a href="genindex.html" title="General Index" |
|
45 accesskey="I">index</a></li> |
|
46 <li class="right" > |
|
47 <a href="py-modindex.html" title="Python Module Index" |
|
48 >modules</a> |</li> |
|
49 <li class="right" > |
|
50 <a href="traverser.html" title="PyAMS namespace traverser" |
|
51 accesskey="N">next</a> |</li> |
|
52 <li class="right" > |
|
53 <a href="zca.html" title="Managing ZCA with PyAMS" |
|
54 accesskey="P">previous</a> |</li> |
|
55 <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> »</li> |
|
56 </ul> |
|
57 </div> |
|
58 |
|
59 <div class="document"> |
|
60 <div class="documentwrapper"> |
|
61 <div class="bodywrapper"> |
|
62 <div class="body" role="main"> |
|
63 |
|
64 <div class="section" id="pyams-site-management"> |
|
65 <span id="site"></span><h1>PyAMS site management<a class="headerlink" href="#pyams-site-management" title="Permalink to this headline">¶</a></h1> |
|
66 <p>PyAMS site management is based on the ZODB.</p> |
|
67 <p>On application startup, if PyAMS_utils package is included into Pyramid configuration, several operations take |
|
68 place:</p> |
|
69 <blockquote> |
|
70 <div><ul class="simple"> |
|
71 <li>a custom <strong>site factory</strong> is defined</li> |
|
72 <li>custom request methods are defined</li> |
|
73 <li>a custom <strong>traverser</strong> handling <strong>namespaces</strong> is defined</li> |
|
74 <li>a custom subscribers predicate based on interfaces support is defined</li> |
|
75 <li>several adapters are registered, to handle annotations and key references</li> |
|
76 <li>custom TALES extensions are registered.</li> |
|
77 </ul> |
|
78 </div></blockquote> |
|
79 <p>The site factory is an important component in this process. It is this factory which will define the application root |
|
80 and create a <strong>local site manager</strong>.</p> |
|
81 <p>Pyramid application is loaded from ZODB’s root via a key defined in Pyramid’s configuration file; the key is named |
|
82 <em>pyams.application_name</em> and it’s default value is <em>application</em>.</p> |
|
83 <p>If the application can’t be found, PyAMS is looking for an application class name in Pyramid’s configuration file; the |
|
84 class name configuration key is called <em>pyams.application_factory</em> and defined by default as |
|
85 <em>pyams_utils.site.BaseSiteRoot</em>. PyAMS default site factory will then create the application, and add a local site |
|
86 manager to it (see <a class="reference internal" href="zca.html#zca"><span class="std std-ref">Managing ZCA with PyAMS</span></a>).</p> |
|
87 <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 |
|
88 notified. Custom packages can subscribe to this event to register custom components.</p> |
|
89 <div class="section" id="pyams-upgrade-command-line-script"> |
|
90 <h2><em>pyams_upgrade</em> command line script<a class="headerlink" href="#pyams-upgrade-command-line-script" title="Permalink to this headline">¶</a></h2> |
|
91 <p>Pyramid allows to define custom command line scripts for application management. A script called <em>pyams_upgrade</em> is |
|
92 provided by PyAMS_utils package; this script apply the same process as PyAMS site factory, but can also be used to |
|
93 manage <strong>database generations</strong>. The idea behind this is just to allow custom packages to provide a way to check and |
|
94 upgrade database configuration away from application startup process:</p> |
|
95 <div class="highlight-bash"><div class="highlight"><pre><span class="c"># ./bin/pyams_upgrade webapp/development.ini</span> |
|
96 </pre></div> |
|
97 </div> |
|
98 <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> |
|
99 interface. For example, <strong>pyams_security</strong> package provides such utility, to make sure that local site manager |
|
100 contains a PyAMS security manager and a principal annotation utility:</p> |
|
101 <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> |
|
102 |
|
103 <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">''</span><span class="p">,</span> <span class="n">SecurityManager</span><span class="p">,</span> <span class="s">'Security manager'</span><span class="p">),</span> |
|
104 <span class="p">(</span><span class="n">IPrincipalAnnotationUtility</span><span class="p">,</span> <span class="s">''</span><span class="p">,</span> <span class="n">PrincipalAnnotationUtility</span><span class="p">,</span> <span class="s">'User profiles'</span><span class="p">))</span> |
|
105 |
|
106 <span class="nd">@utility_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">'PyAMS security'</span><span class="p">,</span> <span class="n">provides</span><span class="o">=</span><span class="n">ISiteGenerations</span><span class="p">)</span> |
|
107 <span class="k">class</span> <span class="nc">SecurityGenerationsChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> |
|
108 <span class="sd">"""I18n generations checker"""</span> |
|
109 |
|
110 <span class="n">generation</span> <span class="o">=</span> <span class="mi">1</span> |
|
111 |
|
112 <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> |
|
113 <span class="sd">"""Check for required utilities"""</span> |
|
114 <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> |
|
115 </pre></div> |
|
116 </div> |
|
117 <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 |
|
118 can to used to verify that a set of local utilities are correctly registered with the given names and interfaces.</p> |
|
119 </div> |
|
120 </div> |
|
121 |
|
122 |
|
123 </div> |
|
124 </div> |
|
125 </div> |
|
126 <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
|
127 <div class="sphinxsidebarwrapper"> |
|
128 <h3><a href="index.html">Table Of Contents</a></h3> |
|
129 <ul> |
|
130 <li><a class="reference internal" href="#">PyAMS site management</a><ul> |
|
131 <li><a class="reference internal" href="#pyams-upgrade-command-line-script"><em>pyams_upgrade</em> command line script</a></li> |
|
132 </ul> |
|
133 </li> |
|
134 </ul> |
|
135 |
|
136 <h4>Previous topic</h4> |
|
137 <p class="topless"><a href="zca.html" |
|
138 title="previous chapter">Managing ZCA with PyAMS</a></p> |
|
139 <h4>Next topic</h4> |
|
140 <p class="topless"><a href="traverser.html" |
|
141 title="next chapter">PyAMS namespace traverser</a></p> |
|
142 <div id="searchbox" style="display: none" role="search"> |
|
143 <h3>Quick search</h3> |
|
144 <form class="search" action="search.html" method="get"> |
|
145 <div><input type="text" name="q" /></div> |
|
146 <div><input type="submit" value="Go" /></div> |
|
147 <input type="hidden" name="check_keywords" value="yes" /> |
|
148 <input type="hidden" name="area" value="default" /> |
|
149 </form> |
|
150 </div> |
|
151 <script type="text/javascript">$('#searchbox').show(0);</script> |
|
152 </div> |
|
153 </div> |
|
154 <div class="clearer"></div> |
|
155 </div> |
|
156 <div class="related" role="navigation" aria-label="related navigation"> |
|
157 <h3>Navigation</h3> |
|
158 <ul> |
|
159 <li class="right" style="margin-right: 10px"> |
|
160 <a href="genindex.html" title="General Index" |
|
161 >index</a></li> |
|
162 <li class="right" > |
|
163 <a href="py-modindex.html" title="Python Module Index" |
|
164 >modules</a> |</li> |
|
165 <li class="right" > |
|
166 <a href="traverser.html" title="PyAMS namespace traverser" |
|
167 >next</a> |</li> |
|
168 <li class="right" > |
|
169 <a href="zca.html" title="Managing ZCA with PyAMS" |
|
170 >previous</a> |</li> |
|
171 <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> »</li> |
|
172 </ul> |
|
173 </div> |
|
174 <div class="footer" role="contentinfo"> |
|
175 © Copyright 2016, Thierry Florac <tflorac@ulthar.net>. |
|
176 Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8. |
|
177 </div> |
|
178 </body> |
|
179 </html> |
|