docs/build/html/tales.html
changeset 79 e12e18e99a68
parent 78 54aeb42c0d80
child 80 137705383aaf
--- a/docs/build/html/tales.html	Tue Nov 22 21:35:46 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-<!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 TALES extensions &#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="Custom PyAMS utilities" href="utilities.html" />
-    <link rel="prev" title="PyAMS namespace traverser" href="traverser.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="utilities.html" title="Custom PyAMS utilities"
-             accesskey="N">next</a> |</li>
-        <li class="right" >
-          <a href="traverser.html" title="PyAMS namespace traverser"
-             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="custom-tales-extensions">
-<span id="tales"></span><h1>Custom TALES extensions<a class="headerlink" href="#custom-tales-extensions" title="Permalink to this headline">ΒΆ</a></h1>
-<p>PyAMS defines a custom expression for TALES called <em>extension</em>.</p>
-<p>When this expression is encountered, the renderer is looking for an
-<code class="xref py py-class docutils literal"><span class="pre">ITALESExtension</span></code>
-multi-adapter for the current <em>context</em>, <em>request</em> and <em>view</em>, for the current
-<em>context</em> and <em>request</em>, or only for the current <em>context</em>, in this order.
-If an adapter is found, the renderer call it&#8217;s <code class="xref py py-func docutils literal"><span class="pre">render()</span></code> method with
-the expression parameters as input parameters.</p>
-<p>For example, the <em>metas</em> extension is an <em>ITALESExtension</em> adapter defined into
-<code class="xref py py-mod docutils literal"><span class="pre">pyams_skin.metas</span></code> module which can be used to include all required headers in
-a page template. Extension is used like this in the page layout template:</p>
-<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;tal:var</span> <span class="na">replace=</span><span class="s">&quot;structure extension:metas&quot;</span> <span class="nt">/&gt;</span>
-</pre></div>
-</div>
-<p>This extension is defined like this:</p>
-<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_skin.interfaces.metas</span> <span class="kn">import</span> <span class="n">IHTMLContentMetas</span>
-<span class="kn">from</span> <span class="nn">pyams_utils.interfaces.tales</span> <span class="kn">import</span> <span class="n">ITALESExtension</span>
-<span class="kn">from</span> <span class="nn">pyramid.interfaces</span> <span class="kn">import</span> <span class="n">IRequest</span>
-
-<span class="kn">from</span> <span class="nn">pyams_utils.adapter</span> <span class="kn">import</span> <span class="n">adapter_config</span><span class="p">,</span> <span class="n">ContextRequestViewAdapter</span>
-
-<span class="nd">@adapter_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;metas&#39;</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="p">(</span><span class="n">Interface</span><span class="p">,</span> <span class="n">IRequest</span><span class="p">,</span> <span class="n">Interface</span><span class="p">),</span> <span class="n">provides</span><span class="o">=</span><span class="n">ITALESExtension</span><span class="p">)</span>
-<span class="k">class</span> <span class="nc">MetasTalesExtension</span><span class="p">(</span><span class="n">ContextRequestViewAdapter</span><span class="p">):</span>
-    <span class="sd">&#39;&#39;&#39;extension:metas TALES extension&#39;&#39;&#39;</span>
-
-    <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">context</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
-        <span class="k">if</span> <span class="n">context</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
-            <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">context</span>
-        <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
-        <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">adapter</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">registry</span><span class="o">.</span><span class="n">getAdapters</span><span class="p">((</span><span class="n">context</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">view</span><span class="p">),</span>
-                                                                      <span class="n">IHTMLContentMetas</span><span class="p">),</span>
-                                    <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s">&#39;order&#39;</span><span class="p">,</span> <span class="mi">9999</span><span class="p">)):</span>
-            <span class="n">result</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="n">meta</span><span class="o">.</span><span class="n">render</span><span class="p">()</span> <span class="k">for</span> <span class="n">meta</span> <span class="ow">in</span> <span class="n">adapter</span><span class="o">.</span><span class="n">get_metas</span><span class="p">()])</span>
-        <span class="k">return</span> <span class="s">&#39;</span><span class="se">\n\t</span><span class="s">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
-</pre></div>
-</div>
-<p>Some TALES extensions can require or accept arguments. For example, the <em>absolute_url</em> extension can accept
-a context and a view name:</p>
-<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;tal:var</span> <span class="na">define=</span><span class="s">&quot;logo config.logo&quot;</span><span class="nt">&gt;</span>
-    <span class="nt">&lt;img</span> <span class="na">tal:attributes=</span><span class="s">&quot;src extension:absolute_url(logo, &#39;++thumb++200x36.png&#39;);&quot;</span> <span class="nt">/&gt;</span>
-<span class="nt">&lt;/tal:var&gt;</span>
-</pre></div>
-</div>
-<p>The extension is defined like this:</p>
-<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">persistent.interfaces</span> <span class="kn">import</span> <span class="n">IPersistent</span>
-<span class="kn">from</span> <span class="nn">pyams_utils.interfaces.tales</span> <span class="kn">import</span> <span class="n">ITALESExtension</span>
-
-<span class="kn">from</span> <span class="nn">pyams_utils.adapter</span> <span class="kn">import</span> <span class="n">adapter_config</span><span class="p">,</span> <span class="n">ContextRequestViewAdapter</span>
-<span class="kn">from</span> <span class="nn">pyramid.url</span> <span class="kn">import</span> <span class="n">resource_url</span>
-<span class="kn">from</span> <span class="nn">zope.interface</span> <span class="kn">import</span> <span class="n">Interface</span>
-
-<span class="nd">@adapter_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;absolute_url&#39;</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="p">(</span><span class="n">IPersistent</span><span class="p">,</span> <span class="n">Interface</span><span class="p">,</span> <span class="n">Interface</span><span class="p">),</span> <span class="n">provides</span><span class="o">=</span><span class="n">ITALESExtension</span><span class="p">)</span>
-<span class="k">class</span> <span class="nc">AbsoluteUrlTalesExtension</span><span class="p">(</span><span class="n">ContextRequestViewAdapter</span><span class="p">):</span>
-    <span class="sd">&#39;&#39;&#39;extension:absolute_url(context, view_name) TALES extension&#39;&#39;&#39;</span>
-
-    <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">context</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">view_name</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
-        <span class="k">if</span> <span class="n">context</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
-            <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">context</span>
-        <span class="k">return</span> <span class="n">resource_url</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span> <span class="n">view_name</span><span class="p">)</span>
-</pre></div>
-</div>
-</div>
-
-
-          </div>
-        </div>
-      </div>
-      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper">
-  <h4>Previous topic</h4>
-  <p class="topless"><a href="traverser.html"
-                        title="previous chapter">PyAMS namespace traverser</a></p>
-  <h4>Next topic</h4>
-  <p class="topless"><a href="utilities.html"
-                        title="next chapter">Custom PyAMS utilities</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="utilities.html" title="Custom PyAMS utilities"
-             >next</a> |</li>
-        <li class="right" >
-          <a href="traverser.html" title="PyAMS namespace traverser"
-             >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