--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/build/html/traverser.html Tue Nov 22 21:35:46 2016 +0100
@@ -0,0 +1,151 @@
+<!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 namespace traverser — 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 TALES extensions" href="tales.html" />
+ <link rel="prev" title="PyAMS site management" href="site.html" />
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Neuton&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&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="tales.html" title="Custom TALES extensions"
+ accesskey="N">next</a> |</li>
+ <li class="right" >
+ <a href="site.html" title="PyAMS site management"
+ accesskey="P">previous</a> |</li>
+ <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body" role="main">
+
+ <div class="section" id="pyams-namespace-traverser">
+<span id="traverser"></span><h1>PyAMS namespace traverser<a class="headerlink" href="#pyams-namespace-traverser" title="Permalink to this headline">¶</a></h1>
+<p>PyAMS_utils provide a custom URL traverser, defined in package <a class="reference internal" href="pyams_utils.html#module-pyams_utils.traversing" title="pyams_utils.traversing"><code class="xref py py-mod docutils literal"><span class="pre">pyams_utils.traversing</span></code></a>.</p>
+<p>The <a class="reference internal" href="pyams_utils.html#pyams_utils.traversing.NamespaceTraverser" title="pyams_utils.traversing.NamespaceTraverser"><code class="xref py py-class docutils literal"><span class="pre">NamespaceTraverser</span></code></a> is a custom traverser based on default
+Pyramid’s <em>ResourceTreeAdapter</em>, but it adds the ability to use <em>namespaces</em>. Inherited from <em>Zope3</em> concept, a
+namespace is a resource path element starting with the « <em>++</em> » characters, like this:</p>
+<div class="highlight-none"><div class="highlight"><pre>http://localhost:5432/folder/content/++ns++argument/@@view.html
+</pre></div>
+</div>
+<p>In this sample, <em>ns</em> is the namespace name. When the traverser detects a namespace, it looks for several named
+adapters (or multi-adapters) to the <code class="xref py py-class docutils literal"><span class="pre">ITraversable</span></code> interface
+defined in <em>zope.traversing</em> package. Adapters lookup with name <em>ns</em> is done for the current <em>context</em> and <em>request</em>,
+then only for the context and finally for the request, in this order. If a traversing adapter is found, it’s
+<code class="xref py py-func docutils literal"><span class="pre">traverse()</span></code> method is called, with the <em>attr</em> value as first argument, and the rest of the traversal stack
+as second one.</p>
+<p>This is for example how a custom <em>etc</em> namespace traverser is defined:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_utils.interfaces.site</span> <span class="kn">import</span> <span class="n">ISiteRoot</span>
+<span class="kn">from</span> <span class="nn">zope.traversing.interfaces</span> <span class="kn">import</span> <span class="n">ITraversable</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">ContextAdapter</span>
+
+<span class="nd">@adapter_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">'etc'</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="n">ISiteRoot</span><span class="p">,</span> <span class="n">provides</span><span class="o">=</span><span class="n">ITraversable</span><span class="p">)</span>
+<span class="k">class</span> <span class="nc">SiteRootEtcTraverser</span><span class="p">(</span><span class="n">ContextAdapter</span><span class="p">):</span>
+ <span class="sd">"""Site root ++etc++ namespace traverser"""</span>
+
+ <span class="k">def</span> <span class="nf">traverse</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">furtherpath</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+ <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s">'site'</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">context</span><span class="o">.</span><span class="n">getSiteManager</span><span class="p">()</span>
+ <span class="k">raise</span> <span class="n">NotFound</span>
+</pre></div>
+</div>
+<p>By using an URL like ‘++etc++site’ on your site root, you can then get access to your local site manager.</p>
+<p><em>argument</em> is not mandatory for the namespace traverser. If it is not provided, the <em>traverse</em> method is called with
+an empty string (with is a default adapter name) as first argument.</p>
+<p>Several PyAMS components use custom traversal adapters. For example, getting thumbnails from an image is done
+through a traversing adapter, which results in nicer URLs than when using classic URLs with arguments...</p>
+</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="site.html"
+ title="previous chapter">PyAMS site management</a></p>
+ <h4>Next topic</h4>
+ <p class="topless"><a href="tales.html"
+ title="next 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="py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li class="right" >
+ <a href="tales.html" title="Custom TALES extensions"
+ >next</a> |</li>
+ <li class="right" >
+ <a href="site.html" title="PyAMS site management"
+ >previous</a> |</li>
+ <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer" role="contentinfo">
+ © Copyright 2016, Thierry Florac <tflorac@ulthar.net>.
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
+ </div>
+ </body>
+</html>
\ No newline at end of file