docs/build/html/pyams_utils.html
changeset 79 e12e18e99a68
parent 78 54aeb42c0d80
child 80 137705383aaf
equal deleted inserted replaced
78:54aeb42c0d80 79:e12e18e99a68
     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_utils package &#8212; 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="stylesheet" href="https://fonts.googleapis.com/css?family=Neuton&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
       
    30 <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" />
       
    31 <!--[if lte IE 6]>
       
    32 <link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
       
    33 <![endif]-->
       
    34 
       
    35   </head>
       
    36   <body role="document">
       
    37 
       
    38     <div class="related" role="navigation" aria-label="related navigation">
       
    39       <h3>Navigation</h3>
       
    40       <ul>
       
    41         <li class="right" style="margin-right: 10px">
       
    42           <a href="genindex.html" title="General Index"
       
    43              accesskey="I">index</a></li>
       
    44         <li class="right" >
       
    45           <a href="py-modindex.html" title="Python Module Index"
       
    46              >modules</a> |</li>
       
    47         <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> &#187;</li> 
       
    48       </ul>
       
    49     </div>  
       
    50 
       
    51     <div class="document">
       
    52       <div class="documentwrapper">
       
    53         <div class="bodywrapper">
       
    54           <div class="body" role="main">
       
    55             
       
    56   <div class="section" id="pyams-utils-package">
       
    57 <h1>pyams_utils package<a class="headerlink" href="#pyams-utils-package" title="Permalink to this headline">¶</a></h1>
       
    58 <div class="section" id="subpackages">
       
    59 <h2>Subpackages<a class="headerlink" href="#subpackages" title="Permalink to this headline">¶</a></h2>
       
    60 <div class="toctree-wrapper compound">
       
    61 <ul>
       
    62 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.interfaces.html">pyams_utils.interfaces package</a><ul>
       
    63 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#submodules">Submodules</a></li>
       
    64 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.data">pyams_utils.interfaces.data module</a></li>
       
    65 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.intids">pyams_utils.interfaces.intids module</a></li>
       
    66 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.site">pyams_utils.interfaces.site module</a></li>
       
    67 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.size">pyams_utils.interfaces.size module</a></li>
       
    68 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.tales">pyams_utils.interfaces.tales module</a></li>
       
    69 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.text">pyams_utils.interfaces.text module</a></li>
       
    70 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.timezone">pyams_utils.interfaces.timezone module</a></li>
       
    71 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.traversing">pyams_utils.interfaces.traversing module</a></li>
       
    72 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.tree">pyams_utils.interfaces.tree module</a></li>
       
    73 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces.zeo">pyams_utils.interfaces.zeo module</a></li>
       
    74 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.interfaces.html#module-pyams_utils.interfaces">Module contents</a></li>
       
    75 </ul>
       
    76 </li>
       
    77 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.protocol.html">pyams_utils.protocol package</a><ul>
       
    78 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.protocol.html#submodules">Submodules</a></li>
       
    79 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.protocol.html#module-pyams_utils.protocol.http">pyams_utils.protocol.http module</a></li>
       
    80 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.protocol.html#module-pyams_utils.protocol.xmlrpc">pyams_utils.protocol.xmlrpc module</a></li>
       
    81 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.protocol.html#module-pyams_utils.protocol">Module contents</a></li>
       
    82 </ul>
       
    83 </li>
       
    84 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.scripts.html">pyams_utils.scripts package</a><ul>
       
    85 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.scripts.html#submodules">Submodules</a></li>
       
    86 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.scripts.html#module-pyams_utils.scripts.zodb">pyams_utils.scripts.zodb module</a></li>
       
    87 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.scripts.html#module-pyams_utils.scripts">Module contents</a></li>
       
    88 </ul>
       
    89 </li>
       
    90 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.tests.html">pyams_utils.tests package</a><ul>
       
    91 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.tests.html#submodules">Submodules</a></li>
       
    92 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.tests.html#module-pyams_utils.tests.test_utilsdocs">pyams_utils.tests.test_utilsdocs module</a></li>
       
    93 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.tests.html#module-pyams_utils.tests.test_utilsdocstrings">pyams_utils.tests.test_utilsdocstrings module</a></li>
       
    94 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.tests.html#module-pyams_utils.tests">Module contents</a></li>
       
    95 </ul>
       
    96 </li>
       
    97 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.timezone.html">pyams_utils.timezone package</a><ul>
       
    98 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.timezone.html#submodules">Submodules</a></li>
       
    99 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.timezone.html#module-pyams_utils.timezone.utility">pyams_utils.timezone.utility module</a></li>
       
   100 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.timezone.html#module-pyams_utils.timezone.vocabulary">pyams_utils.timezone.vocabulary module</a></li>
       
   101 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.timezone.html#module-pyams_utils.timezone">Module contents</a></li>
       
   102 </ul>
       
   103 </li>
       
   104 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.widget.html">pyams_utils.widget package</a><ul>
       
   105 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.widget.html#submodules">Submodules</a></li>
       
   106 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.widget.html#module-pyams_utils.widget.decimal">pyams_utils.widget.decimal module</a></li>
       
   107 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.widget.html#module-pyams_utils.widget">Module contents</a></li>
       
   108 </ul>
       
   109 </li>
       
   110 <li class="toctree-l1"><a class="reference internal" href="pyams_utils.zmi.html">pyams_utils.zmi package</a><ul>
       
   111 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.zmi.html#submodules">Submodules</a></li>
       
   112 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.zmi.html#module-pyams_utils.zmi.intids">pyams_utils.zmi.intids module</a></li>
       
   113 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.zmi.html#module-pyams_utils.zmi.timezone">pyams_utils.zmi.timezone module</a></li>
       
   114 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.zmi.html#module-pyams_utils.zmi.zeo">pyams_utils.zmi.zeo module</a></li>
       
   115 <li class="toctree-l2"><a class="reference internal" href="pyams_utils.zmi.html#module-pyams_utils.zmi">Module contents</a></li>
       
   116 </ul>
       
   117 </li>
       
   118 </ul>
       
   119 </div>
       
   120 </div>
       
   121 <div class="section" id="submodules">
       
   122 <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
       
   123 </div>
       
   124 <div class="section" id="module-pyams_utils.adapter">
       
   125 <span id="pyams-utils-adapter-module"></span><h2>pyams_utils.adapter module<a class="headerlink" href="#module-pyams_utils.adapter" title="Permalink to this headline">¶</a></h2>
       
   126 <p>Adapters management package</p>
       
   127 <p>This package provides a small set of standard base adapters for <em>context</em>, <em>context</em> and <em>request</em>, and
       
   128 <em>context</em> and <em>request</em> and <em>view</em>.</p>
       
   129 <p>See <a class="reference internal" href="zca.html#zca"><span class="std std-ref">Managing ZCA with PyAMS</span></a> to see how PyAMS can help components management.</p>
       
   130 <dl class="class">
       
   131 <dt id="pyams_utils.adapter.ContextAdapter">
       
   132 <em class="property">class </em><code class="descclassname">pyams_utils.adapter.</code><code class="descname">ContextAdapter</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.adapter.ContextAdapter" title="Permalink to this definition">¶</a></dt>
       
   133 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   134 <p>Context adapter</p>
       
   135 </dd></dl>
       
   136 
       
   137 <dl class="class">
       
   138 <dt id="pyams_utils.adapter.ContextRequestAdapter">
       
   139 <em class="property">class </em><code class="descclassname">pyams_utils.adapter.</code><code class="descname">ContextRequestAdapter</code><span class="sig-paren">(</span><em>context</em>, <em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.adapter.ContextRequestAdapter" title="Permalink to this definition">¶</a></dt>
       
   140 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   141 <p>Context + request multi-adapter</p>
       
   142 </dd></dl>
       
   143 
       
   144 <dl class="class">
       
   145 <dt id="pyams_utils.adapter.ContextRequestViewAdapter">
       
   146 <em class="property">class </em><code class="descclassname">pyams_utils.adapter.</code><code class="descname">ContextRequestViewAdapter</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="Permalink to this definition">¶</a></dt>
       
   147 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   148 <p>Context + request + view multi-adapter</p>
       
   149 </dd></dl>
       
   150 
       
   151 <dl class="class">
       
   152 <dt id="pyams_utils.adapter.adapter_config">
       
   153 <em class="property">class </em><code class="descclassname">pyams_utils.adapter.</code><code class="descname">adapter_config</code><span class="sig-paren">(</span><em>**settings</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.adapter.adapter_config" title="Permalink to this definition">¶</a></dt>
       
   154 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   155 <p>Function or class decorator to declare an adapter</p>
       
   156 <p>Annotation parameters can be:</p>
       
   157 <table class="docutils field-list" frame="void" rules="none">
       
   158 <col class="field-name" />
       
   159 <col class="field-body" />
       
   160 <tbody valign="top">
       
   161 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
   162 <li><strong>name</strong> (<em>str</em>) &#8211; (default=&#8217;&#8216;), name of the adapter</li>
       
   163 <li><strong>context</strong> (<em>[Interface...]</em>) &#8211; an interface, or a tuple of interfaces, that the component adapts</li>
       
   164 <li><strong>provides</strong> (<em>Interface</em>) &#8211; the interface that the adapter provides</li>
       
   165 </ul>
       
   166 </td>
       
   167 </tr>
       
   168 </tbody>
       
   169 </table>
       
   170 <dl class="attribute">
       
   171 <dt id="pyams_utils.adapter.adapter_config.venusian">
       
   172 <code class="descname">venusian</code><em class="property"> = &lt;module 'venusian' from '/var/local/env/pyams/eggs/venusian-1.0-py3.4.egg/venusian/__init__.py'&gt;</em><a class="headerlink" href="#pyams_utils.adapter.adapter_config.venusian" title="Permalink to this definition">¶</a></dt>
       
   173 <dd></dd></dl>
       
   174 
       
   175 </dd></dl>
       
   176 
       
   177 </div>
       
   178 <div class="section" id="module-pyams_utils.attr">
       
   179 <span id="pyams-utils-attr-module"></span><h2>pyams_utils.attr module<a class="headerlink" href="#module-pyams_utils.attr" title="Permalink to this headline">¶</a></h2>
       
   180 <dl class="class">
       
   181 <dt id="pyams_utils.attr.AttributeTraverser">
       
   182 <em class="property">class </em><code class="descclassname">pyams_utils.attr.</code><code class="descname">AttributeTraverser</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.attr.AttributeTraverser" title="Permalink to this definition">¶</a></dt>
       
   183 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
   184 <p>++attr++ namespace traverser</p>
       
   185 <p>This custom traversing adapter can be used to access an object attribute directly from
       
   186 an URL by using a path like this:</p>
       
   187 <div class="highlight-default"><div class="highlight"><pre><span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="nb">object</span><span class="o">/++</span><span class="n">attr</span><span class="o">++</span><span class="n">name</span>
       
   188 </pre></div>
       
   189 </div>
       
   190 <p>Whare <em>name</em> is the name of the requested attribute</p>
       
   191 <dl class="method">
       
   192 <dt id="pyams_utils.attr.AttributeTraverser.traverse">
       
   193 <code class="descname">traverse</code><span class="sig-paren">(</span><em>name</em>, <em>furtherpath=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.attr.AttributeTraverser.traverse" title="Permalink to this definition">¶</a></dt>
       
   194 <dd></dd></dl>
       
   195 
       
   196 </dd></dl>
       
   197 
       
   198 </div>
       
   199 <div class="section" id="module-pyams_utils.container">
       
   200 <span id="pyams-utils-container-module"></span><h2>pyams_utils.container module<a class="headerlink" href="#module-pyams_utils.container" title="Permalink to this headline">¶</a></h2>
       
   201 <dl class="class">
       
   202 <dt id="pyams_utils.container.BTreeOrderedContainer">
       
   203 <em class="property">class </em><code class="descclassname">pyams_utils.container.</code><code class="descname">BTreeOrderedContainer</code><a class="headerlink" href="#pyams_utils.container.BTreeOrderedContainer" title="Permalink to this definition">¶</a></dt>
       
   204 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.container.ordered.OrderedContainer</span></code></p>
       
   205 <p>BTree based ordered container</p>
       
   206 <p>This container maintain a manual order of it&#8217;s contents</p>
       
   207 </dd></dl>
       
   208 
       
   209 <dl class="class">
       
   210 <dt id="pyams_utils.container.ContainerSublocationsAdapter">
       
   211 <em class="property">class </em><code class="descclassname">pyams_utils.container.</code><code class="descname">ContainerSublocationsAdapter</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.container.ContainerSublocationsAdapter" title="Permalink to this definition">¶</a></dt>
       
   212 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
   213 <p>Contained object sub-locations adapter</p>
       
   214 <p>This adapter checks for custom ISublocations interface adapters which can
       
   215 be defined by any component to get access to inner locations, defined for
       
   216 example via annotations.</p>
       
   217 <dl class="method">
       
   218 <dt id="pyams_utils.container.ContainerSublocationsAdapter.sublocations">
       
   219 <code class="descname">sublocations</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.container.ContainerSublocationsAdapter.sublocations" title="Permalink to this definition">¶</a></dt>
       
   220 <dd><p>See <cite>zope.location.interfaces.ISublocations</cite> interface</p>
       
   221 </dd></dl>
       
   222 
       
   223 </dd></dl>
       
   224 
       
   225 <dl class="function">
       
   226 <dt id="pyams_utils.container.find_objects_matching">
       
   227 <code class="descclassname">pyams_utils.container.</code><code class="descname">find_objects_matching</code><span class="sig-paren">(</span><em>root</em>, <em>condition</em>, <em>ignore_root=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.container.find_objects_matching" title="Permalink to this definition">¶</a></dt>
       
   228 <dd><p>Find all objects in root that match the condition</p>
       
   229 <p>The condition is a Python callable object that takes an object as
       
   230 argument and must return a boolean result.</p>
       
   231 <p>All sub-objects of the root will also be searched recursively.</p>
       
   232 <table class="docutils field-list" frame="void" rules="none">
       
   233 <col class="field-name" />
       
   234 <col class="field-body" />
       
   235 <tbody valign="top">
       
   236 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   237 <li><strong>root</strong> (<em>object</em>) &#8211; the parent object from which search is started</li>
       
   238 <li><strong>condition</strong> (<em>callable</em>) &#8211; a callable object which may return true for a given
       
   239 object to be selected</li>
       
   240 <li><strong>ignore_root</strong> (<em>boolean</em>) &#8211; if <em>True</em>, the root object will not be returned, even if it matches
       
   241 the given condition</li>
       
   242 </ul>
       
   243 </td>
       
   244 </tr>
       
   245 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">an iterator for all root&#8217;s sub-objects matching condition</p>
       
   246 </td>
       
   247 </tr>
       
   248 </tbody>
       
   249 </table>
       
   250 </dd></dl>
       
   251 
       
   252 <dl class="function">
       
   253 <dt id="pyams_utils.container.find_objects_providing">
       
   254 <code class="descclassname">pyams_utils.container.</code><code class="descname">find_objects_providing</code><span class="sig-paren">(</span><em>root</em>, <em>interface</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.container.find_objects_providing" title="Permalink to this definition">¶</a></dt>
       
   255 <dd><p>Find all objects in root that provide the specified interface</p>
       
   256 <p>All sub-objects of the root will also be searched recursively.</p>
       
   257 <table class="docutils field-list" frame="void" rules="none">
       
   258 <col class="field-name" />
       
   259 <col class="field-body" />
       
   260 <tbody valign="top">
       
   261 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   262 <li><strong>root</strong> (<em>object</em>) &#8211; object; the parent object from which search is started</li>
       
   263 <li><strong>interface</strong> (<em>Interface</em>) &#8211; interface; an interface that sub-objects should provide</li>
       
   264 </ul>
       
   265 </td>
       
   266 </tr>
       
   267 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">an iterator for all root&#8217;s sub-objects that provide the given interface</p>
       
   268 </td>
       
   269 </tr>
       
   270 </tbody>
       
   271 </table>
       
   272 </dd></dl>
       
   273 
       
   274 </div>
       
   275 <div class="section" id="module-pyams_utils.context">
       
   276 <span id="pyams-utils-context-module"></span><h2>pyams_utils.context module<a class="headerlink" href="#module-pyams_utils.context" title="Permalink to this headline">¶</a></h2>
       
   277 <dl class="class">
       
   278 <dt id="pyams_utils.context.ContextSelector">
       
   279 <em class="property">class </em><code class="descclassname">pyams_utils.context.</code><code class="descname">ContextSelector</code><span class="sig-paren">(</span><em>ifaces</em>, <em>config</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.context.ContextSelector" title="Permalink to this definition">¶</a></dt>
       
   280 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   281 <p>Interface based context selector</p>
       
   282 <p>This selector can be used as a subscriber predicate to define
       
   283 an interface that the context must support for the event to be applied:</p>
       
   284 <div class="highlight-default"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_utils.interfaces.site</span> <span class="k">import</span> <span class="n">ISiteRoot</span>
       
   285 
       
   286 <span class="nd">@subscriber</span><span class="p">(</span><span class="n">IObjectModifiedEvent</span><span class="p">,</span> <span class="n">context_selector</span><span class="o">=</span><span class="n">ISiteRoot</span><span class="p">)</span>
       
   287 <span class="k">def</span> <span class="nf">siteroot_modified_event_handler</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
       
   288     <span class="sd">&#39;&#39;&#39;This is an event handler for an ISiteRoot object modification event&#39;&#39;&#39;</span>
       
   289 </pre></div>
       
   290 </div>
       
   291 <dl class="method">
       
   292 <dt id="pyams_utils.context.ContextSelector.phash">
       
   293 <code class="descname">phash</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.context.ContextSelector.phash" title="Permalink to this definition">¶</a></dt>
       
   294 <dd></dd></dl>
       
   295 
       
   296 <dl class="method">
       
   297 <dt id="pyams_utils.context.ContextSelector.text">
       
   298 <code class="descname">text</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.context.ContextSelector.text" title="Permalink to this definition">¶</a></dt>
       
   299 <dd></dd></dl>
       
   300 
       
   301 </dd></dl>
       
   302 
       
   303 </div>
       
   304 <div class="section" id="module-pyams_utils.data">
       
   305 <span id="pyams-utils-data-module"></span><h2>pyams_utils.data module<a class="headerlink" href="#module-pyams_utils.data" title="Permalink to this headline">¶</a></h2>
       
   306 <p>Object data API module</p>
       
   307 <p>The <em>IObjectData</em> interface is a generic interface which can be used to assign custom data to nay object.
       
   308 This object data may be any object which can be serialized to JSON, and assigned to any HTML <em>data</em> attribute.
       
   309 It can typically be used to set a <em>data-ams-data</em> attribute to objects, which is afterwards converted to
       
   310 classic <em>data-</em> attributes by <strong>MyAMS.js</strong> framework.</p>
       
   311 <p>For example, for a custom widget in a form:</p>
       
   312 <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">updateWidgets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
       
   313     <span class="nb">super</span><span class="p">(</span><span class="n">MyForm</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">updateWidgets</span><span class="p">()</span>
       
   314     <span class="n">widget</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">widgets</span><span class="p">[</span><span class="s">&#39;mywidget&#39;</span><span class="p">]</span>
       
   315     <span class="n">alsoProvides</span><span class="p">(</span><span class="n">widget</span><span class="p">,</span> <span class="n">IObjectData</span><span class="p">)</span>
       
   316     <span class="n">widget</span><span class="o">.</span><span class="n">object_data</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;ams-colorpicker-position&#39;</span><span class="p">:</span> <span class="s">&#39;top left&#39;</span><span class="p">}</span>
       
   317 </pre></div>
       
   318 </div>
       
   319 <p>You can then set an attribute in a TAL template like this:</p>
       
   320 <div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;div</span> <span class="na">tal:attributes=</span><span class="s">&quot;data-ams-data extension:object_data(widget)&quot;</span><span class="nt">&gt;</span>...<span class="nt">&lt;/div&gt;</span>
       
   321 </pre></div>
       
   322 </div>
       
   323 <p>After data initialization by <strong>MyAMS.js</strong>, the following code will be converted to:</p>
       
   324 <div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;div</span> <span class="na">data-ams-colorpicker-position=</span><span class="s">&quot;top left&quot;</span><span class="nt">&gt;</span>...<span class="nt">&lt;/div&gt;</span>
       
   325 </pre></div>
       
   326 </div>
       
   327 <dl class="class">
       
   328 <dt id="pyams_utils.data.BrowserRequestDataExtension">
       
   329 <em class="property">class </em><code class="descclassname">pyams_utils.data.</code><code class="descname">BrowserRequestDataExtension</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.BrowserRequestDataExtension" title="Permalink to this definition">¶</a></dt>
       
   330 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="pyams_utils.adapter.ContextRequestViewAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextRequestViewAdapter</span></code></a></p>
       
   331 <p>extension:request_data TALES extension for Zope browser request</p>
       
   332 <p>This TALES extension can be used to get a request data, previously stored in the request via an annotation.
       
   333 For example:</p>
       
   334 <div class="highlight-default"><div class="highlight"><pre><span class="o">&lt;</span><span class="n">div</span> <span class="n">tal</span><span class="p">:</span><span class="n">content</span><span class="o">=</span><span class="s">&quot;extension:request_data(&#39;my.annotation.key&#39;)&quot;</span><span class="o">&gt;...&lt;/</span><span class="n">div</span><span class="o">&gt;</span>
       
   335 </pre></div>
       
   336 </div>
       
   337 <dl class="method">
       
   338 <dt id="pyams_utils.data.BrowserRequestDataExtension.render">
       
   339 <code class="descname">render</code><span class="sig-paren">(</span><em>params=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.BrowserRequestDataExtension.render" title="Permalink to this definition">¶</a></dt>
       
   340 <dd><p>See <cite>pyams_utils.interfaces.tales.ITALESExtension</cite> interface</p>
       
   341 </dd></dl>
       
   342 
       
   343 </dd></dl>
       
   344 
       
   345 <dl class="class">
       
   346 <dt id="pyams_utils.data.ObjectDataExtension">
       
   347 <em class="property">class </em><code class="descclassname">pyams_utils.data.</code><code class="descname">ObjectDataExtension</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.ObjectDataExtension" title="Permalink to this definition">¶</a></dt>
       
   348 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="pyams_utils.adapter.ContextRequestViewAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextRequestViewAdapter</span></code></a></p>
       
   349 <p>extension:object_data TALES extension</p>
       
   350 <p>This TALES extension is to be used in Chameleon templates to define a custom data attribute
       
   351 which stores all object data (see <cite>pyams_utils.interfaces.data.IObjectData</cite> interface), like this:</p>
       
   352 <div class="highlight-default"><div class="highlight"><pre><span class="o">&lt;</span><span class="n">div</span> <span class="n">tal</span><span class="p">:</span><span class="n">attributes</span><span class="o">=</span><span class="s">&quot;data-ams-data extension:object_data(context)&quot;</span><span class="o">&gt;...&lt;/</span><span class="n">div</span><span class="o">&gt;</span>
       
   353 </pre></div>
       
   354 </div>
       
   355 <dl class="method">
       
   356 <dt id="pyams_utils.data.ObjectDataExtension.render">
       
   357 <code class="descname">render</code><span class="sig-paren">(</span><em>context=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.ObjectDataExtension.render" title="Permalink to this definition">¶</a></dt>
       
   358 <dd><p>See <cite>pyams_utils.interfaces.tales.ITALESExtension</cite> interface</p>
       
   359 </dd></dl>
       
   360 
       
   361 </dd></dl>
       
   362 
       
   363 <dl class="class">
       
   364 <dt id="pyams_utils.data.ObjectDataRenderer">
       
   365 <em class="property">class </em><code class="descclassname">pyams_utils.data.</code><code class="descname">ObjectDataRenderer</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.ObjectDataRenderer" title="Permalink to this definition">¶</a></dt>
       
   366 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
   367 <p>Object data JSON renderer</p>
       
   368 <dl class="method">
       
   369 <dt id="pyams_utils.data.ObjectDataRenderer.get_object_data">
       
   370 <code class="descname">get_object_data</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.ObjectDataRenderer.get_object_data" title="Permalink to this definition">¶</a></dt>
       
   371 <dd><p>See <cite>pyams_utils.interfaces.data.IObjectDataRenderer</cite> interface</p>
       
   372 </dd></dl>
       
   373 
       
   374 </dd></dl>
       
   375 
       
   376 <dl class="class">
       
   377 <dt id="pyams_utils.data.PyramidRequestDataExtension">
       
   378 <em class="property">class </em><code class="descclassname">pyams_utils.data.</code><code class="descname">PyramidRequestDataExtension</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.PyramidRequestDataExtension" title="Permalink to this definition">¶</a></dt>
       
   379 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="pyams_utils.adapter.ContextRequestViewAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextRequestViewAdapter</span></code></a></p>
       
   380 <p>extension:request_data TALES extension for Pyramid request</p>
       
   381 <p>This TALES extension can be used to get a request data, previously stored in the request via an annotation.
       
   382 For example:</p>
       
   383 <div class="highlight-default"><div class="highlight"><pre><span class="o">&lt;</span><span class="n">div</span> <span class="n">tal</span><span class="p">:</span><span class="n">content</span><span class="o">=</span><span class="s">&quot;extension:request_data(&#39;my.annotation.key&#39;)&quot;</span><span class="o">&gt;...&lt;/</span><span class="n">div</span><span class="o">&gt;</span>
       
   384 </pre></div>
       
   385 </div>
       
   386 <dl class="method">
       
   387 <dt id="pyams_utils.data.PyramidRequestDataExtension.render">
       
   388 <code class="descname">render</code><span class="sig-paren">(</span><em>params=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.data.PyramidRequestDataExtension.render" title="Permalink to this definition">¶</a></dt>
       
   389 <dd><p>See <cite>pyams_utils.interfaces.tales.ITALESExtension</cite> interface</p>
       
   390 </dd></dl>
       
   391 
       
   392 </dd></dl>
       
   393 
       
   394 </div>
       
   395 <div class="section" id="module-pyams_utils.date">
       
   396 <span id="pyams-utils-date-module"></span><h2>pyams_utils.date module<a class="headerlink" href="#module-pyams_utils.date" title="Permalink to this headline">¶</a></h2>
       
   397 <dl class="function">
       
   398 <dt id="pyams_utils.date.date_to_datetime">
       
   399 <code class="descclassname">pyams_utils.date.</code><code class="descname">date_to_datetime</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.date_to_datetime" title="Permalink to this definition">¶</a></dt>
       
   400 <dd><p>Get datetime value converted from a date or datetime object</p>
       
   401 <table class="docutils field-list" frame="void" rules="none">
       
   402 <col class="field-name" />
       
   403 <col class="field-body" />
       
   404 <tbody valign="top">
       
   405 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<em>date/datetime</em>) &#8211; a date or datetime value to convert</td>
       
   406 </tr>
       
   407 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">datetime; input value converted to datetime</td>
       
   408 </tr>
       
   409 </tbody>
       
   410 </table>
       
   411 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">date</span><span class="p">,</span> <span class="n">datetime</span>
       
   412 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">date_to_datetime</span>
       
   413 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span> <span class="o">=</span> <span class="n">date</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
       
   414 <span class="gp">&gt;&gt;&gt; </span><span class="n">date_to_datetime</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
       
   415 <span class="go">datetime.datetime(2016, 11, 15, 0, 0)</span>
       
   416 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
       
   417 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span>
       
   418 <span class="go">datetime.datetime(2016, 11, 15, 10, 13, 12)</span>
       
   419 <span class="gp">&gt;&gt;&gt; </span><span class="n">date_to_datetime</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="ow">is</span> <span class="n">value</span>
       
   420 <span class="go">True</span>
       
   421 </pre></div>
       
   422 </div>
       
   423 </dd></dl>
       
   424 
       
   425 <dl class="function">
       
   426 <dt id="pyams_utils.date.format_date">
       
   427 <code class="descclassname">pyams_utils.date.</code><code class="descname">format_date</code><span class="sig-paren">(</span><em>value</em>, <em>format='on %d/%m/%Y'</em>, <em>request=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.format_date" title="Permalink to this definition">¶</a></dt>
       
   428 <dd><p>Format given date with the given format</p>
       
   429 <table class="docutils field-list" frame="void" rules="none">
       
   430 <col class="field-name" />
       
   431 <col class="field-body" />
       
   432 <tbody valign="top">
       
   433 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   434 <li><strong>value</strong> (<em>datetime</em>) &#8211; the value to format</li>
       
   435 <li><strong>format</strong> (<em>str</em>) &#8211; a format string to use by <cite>strftime</cite> function</li>
       
   436 <li><strong>request</strong> &#8211; the request from which to extract localization info for translation</li>
       
   437 </ul>
       
   438 </td>
       
   439 </tr>
       
   440 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str; input datetime converted to given format</p>
       
   441 </td>
       
   442 </tr>
       
   443 </tbody>
       
   444 </table>
       
   445 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span>
       
   446 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">format_date</span><span class="p">,</span> <span class="n">SH_DATE_FORMAT</span>
       
   447 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
       
   448 <span class="gp">&gt;&gt;&gt; </span><span class="n">format_date</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
       
   449 <span class="go">&#39;on 15/11/2016&#39;</span>
       
   450 <span class="gp">&gt;&gt;&gt; </span><span class="n">format_date</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">SH_DATE_FORMAT</span><span class="p">)</span>
       
   451 <span class="go">&#39;15/11/2016&#39;</span>
       
   452 </pre></div>
       
   453 </div>
       
   454 </dd></dl>
       
   455 
       
   456 <dl class="function">
       
   457 <dt id="pyams_utils.date.format_datetime">
       
   458 <code class="descclassname">pyams_utils.date.</code><code class="descname">format_datetime</code><span class="sig-paren">(</span><em>value</em>, <em>format='on %d/%m/%Y at %H:%M'</em>, <em>request=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.format_datetime" title="Permalink to this definition">¶</a></dt>
       
   459 <dd><p>Format given datetime with the given format including time</p>
       
   460 <table class="docutils field-list" frame="void" rules="none">
       
   461 <col class="field-name" />
       
   462 <col class="field-body" />
       
   463 <tbody valign="top">
       
   464 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   465 <li><strong>value</strong> (<em>datetime</em>) &#8211; the value to format</li>
       
   466 <li><strong>format</strong> (<em>str</em>) &#8211; a format string to use by <cite>strftime</cite> function</li>
       
   467 <li><strong>request</strong> &#8211; request; the request from which to extract localization info for translation</li>
       
   468 </ul>
       
   469 </td>
       
   470 </tr>
       
   471 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str; input datetime converted to given format</p>
       
   472 </td>
       
   473 </tr>
       
   474 </tbody>
       
   475 </table>
       
   476 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span>
       
   477 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">format_datetime</span><span class="p">,</span> <span class="n">SH_DATETIME_FORMAT</span>
       
   478 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
       
   479 <span class="gp">&gt;&gt;&gt; </span><span class="n">format_datetime</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
       
   480 <span class="go">&#39;on 15/11/2016 at 10:13&#39;</span>
       
   481 <span class="gp">&gt;&gt;&gt; </span><span class="n">format_datetime</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">SH_DATETIME_FORMAT</span><span class="p">)</span>
       
   482 <span class="go">&#39;15/11/2016 - 10:13&#39;</span>
       
   483 </pre></div>
       
   484 </div>
       
   485 </dd></dl>
       
   486 
       
   487 <dl class="function">
       
   488 <dt id="pyams_utils.date.get_age">
       
   489 <code class="descclassname">pyams_utils.date.</code><code class="descname">get_age</code><span class="sig-paren">(</span><em>value</em>, <em>request=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.get_age" title="Permalink to this definition">¶</a></dt>
       
   490 <dd><p>Get &#8216;human&#8217; age of a given datetime (including timezone) compared to current datetime (in UTC)</p>
       
   491 <table class="docutils field-list" frame="void" rules="none">
       
   492 <col class="field-name" />
       
   493 <col class="field-body" />
       
   494 <tbody valign="top">
       
   495 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<em>datetime</em>) &#8211; input datetime to be compared with current datetime</td>
       
   496 </tr>
       
   497 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">str; the delta value, converted to months, weeks, days, hours or minutes</td>
       
   498 </tr>
       
   499 </tbody>
       
   500 </table>
       
   501 </dd></dl>
       
   502 
       
   503 <dl class="function">
       
   504 <dt id="pyams_utils.date.get_duration">
       
   505 <code class="descclassname">pyams_utils.date.</code><code class="descname">get_duration</code><span class="sig-paren">(</span><em>v1</em>, <em>v2=None</em>, <em>request=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.get_duration" title="Permalink to this definition">¶</a></dt>
       
   506 <dd><p>Get &#8216;human&#8217; delta as string between two dates</p>
       
   507 <table class="docutils field-list" frame="void" rules="none">
       
   508 <col class="field-name" />
       
   509 <col class="field-body" />
       
   510 <tbody valign="top">
       
   511 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   512 <li><strong>v1</strong> (<em>datetime</em>) &#8211; start date</li>
       
   513 <li><strong>v2</strong> (<em>datetime</em>) &#8211; end date, or current date (in UTC) if None</li>
       
   514 <li><strong>request</strong> &#8211; the request from which to extract localization infos</li>
       
   515 </ul>
       
   516 </td>
       
   517 </tr>
       
   518 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str; approximate delta between the two input dates</p>
       
   519 </td>
       
   520 </tr>
       
   521 </tbody>
       
   522 </table>
       
   523 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span>
       
   524 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">get_duration</span>
       
   525 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyramid.testing</span> <span class="k">import</span> <span class="n">DummyRequest</span>
       
   526 <span class="gp">&gt;&gt;&gt; </span><span class="n">request</span> <span class="o">=</span> <span class="n">DummyRequest</span><span class="p">()</span>
       
   527 <span class="gp">&gt;&gt;&gt; </span><span class="n">date1</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
       
   528 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2014</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
       
   529 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   530 <span class="go">&#39;10 months&#39;</span>
       
   531 </pre></div>
       
   532 </div>
       
   533 <p>Dates order is not important:</p>
       
   534 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date2</span><span class="p">,</span> <span class="n">date1</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   535 <span class="go">&#39;10 months&#39;</span>
       
   536 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2014</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
       
   537 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   538 <span class="go">&#39;7 weeks&#39;</span>
       
   539 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2014</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">26</span><span class="p">)</span>
       
   540 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   541 <span class="go">&#39;6 days&#39;</span>
       
   542 </pre></div>
       
   543 </div>
       
   544 <p>For durations lower than 2 days, duration also display hours:</p>
       
   545 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">date1</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
       
   546 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
       
   547 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   548 <span class="go">&#39;1 day and 15 hours&#39;</span>
       
   549 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
       
   550 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   551 <span class="go">&#39;24 hours&#39;</span>
       
   552 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
       
   553 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   554 <span class="go">&#39;13 hours&#39;</span>
       
   555 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
       
   556 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   557 <span class="go">&#39;75 minutes&#39;</span>
       
   558 <span class="gp">&gt;&gt;&gt; </span><span class="n">date2</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2015</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
       
   559 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_duration</span><span class="p">(</span><span class="n">date1</span><span class="p">,</span> <span class="n">date2</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
   560 <span class="go">&#39;15 seconds&#39;</span>
       
   561 </pre></div>
       
   562 </div>
       
   563 </dd></dl>
       
   564 
       
   565 <dl class="function">
       
   566 <dt id="pyams_utils.date.parse_date">
       
   567 <code class="descclassname">pyams_utils.date.</code><code class="descname">parse_date</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.parse_date" title="Permalink to this definition">¶</a></dt>
       
   568 <dd><p>Get date specified in unicode ISO format to Python datetime object</p>
       
   569 <p>Dates are always assumed to be stored in GMT timezone</p>
       
   570 <table class="docutils field-list" frame="void" rules="none">
       
   571 <col class="field-name" />
       
   572 <col class="field-body" />
       
   573 <tbody valign="top">
       
   574 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<em>str</em>) &#8211; unicode date to be parsed</td>
       
   575 </tr>
       
   576 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">datetime; the specified value, converted to datetime</td>
       
   577 </tr>
       
   578 </tbody>
       
   579 </table>
       
   580 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">parse_date</span>
       
   581 <span class="gp">&gt;&gt;&gt; </span><span class="n">parse_date</span><span class="p">(</span><span class="s">&#39;2016-11-15T10:13:12+00:00&#39;</span><span class="p">)</span>
       
   582 <span class="go">datetime.datetime(2016, 11, 15, 10, 13, 12, tzinfo=&lt;StaticTzInfo &#39;GMT&#39;&gt;)</span>
       
   583 </pre></div>
       
   584 </div>
       
   585 </dd></dl>
       
   586 
       
   587 <dl class="function">
       
   588 <dt id="pyams_utils.date.unidate">
       
   589 <code class="descclassname">pyams_utils.date.</code><code class="descname">unidate</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.date.unidate" title="Permalink to this definition">¶</a></dt>
       
   590 <dd><p>Get specified date converted to unicode ISO format</p>
       
   591 <p>Dates are always assumed to be stored in GMT timezone</p>
       
   592 <table class="docutils field-list" frame="void" rules="none">
       
   593 <col class="field-name" />
       
   594 <col class="field-body" />
       
   595 <tbody valign="top">
       
   596 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<a class="reference internal" href="#module-pyams_utils.date" title="pyams_utils.date"><em>date</em></a>) &#8211; input date to convert to unicode</td>
       
   597 </tr>
       
   598 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">unicode; input date converted to unicode</td>
       
   599 </tr>
       
   600 </tbody>
       
   601 </table>
       
   602 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span>
       
   603 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.date</span> <span class="k">import</span> <span class="n">unidate</span>
       
   604 <span class="gp">&gt;&gt;&gt; </span><span class="n">value</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
       
   605 <span class="gp">&gt;&gt;&gt; </span><span class="n">unidate</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
       
   606 <span class="go">&#39;2016-11-15T10:13:12+00:00&#39;</span>
       
   607 </pre></div>
       
   608 </div>
       
   609 </dd></dl>
       
   610 
       
   611 </div>
       
   612 <div class="section" id="module-pyams_utils.decorator">
       
   613 <span id="pyams-utils-decorator-module"></span><h2>pyams_utils.decorator module<a class="headerlink" href="#module-pyams_utils.decorator" title="Permalink to this headline">¶</a></h2>
       
   614 <dl class="function">
       
   615 <dt id="pyams_utils.decorator.deprecated">
       
   616 <code class="descclassname">pyams_utils.decorator.</code><code class="descname">deprecated</code><span class="sig-paren">(</span><em>*msg</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.decorator.deprecated" title="Permalink to this definition">¶</a></dt>
       
   617 <dd><p>This is a decorator which can be used to mark functions
       
   618 as deprecated. It will result in a warning being emitted
       
   619 when the function is used.</p>
       
   620 </dd></dl>
       
   621 
       
   622 </div>
       
   623 <div class="section" id="module-pyams_utils.encoding">
       
   624 <span id="pyams-utils-encoding-module"></span><h2>pyams_utils.encoding module<a class="headerlink" href="#module-pyams_utils.encoding" title="Permalink to this headline">¶</a></h2>
       
   625 <dl class="class">
       
   626 <dt id="pyams_utils.encoding.EncodingField">
       
   627 <em class="property">class </em><code class="descclassname">pyams_utils.encoding.</code><code class="descname">EncodingField</code><span class="sig-paren">(</span><em>vocabulary='PyAMS encodings'</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.encoding.EncodingField" title="Permalink to this definition">¶</a></dt>
       
   628 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.Choice</span></code></p>
       
   629 <p>Encoding schema field</p>
       
   630 </dd></dl>
       
   631 
       
   632 <dl class="class">
       
   633 <dt id="pyams_utils.encoding.EncodingsVocabulary">
       
   634 <em class="property">class </em><code class="descclassname">pyams_utils.encoding.</code><code class="descname">EncodingsVocabulary</code><span class="sig-paren">(</span><em>terms</em>, <em>*interfaces</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.encoding.EncodingsVocabulary" title="Permalink to this definition">¶</a></dt>
       
   635 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema.vocabulary.SimpleVocabulary</span></code></p>
       
   636 <p>A vocabulary containing a set of registered encodings</p>
       
   637 </dd></dl>
       
   638 
       
   639 </div>
       
   640 <div class="section" id="module-pyams_utils.html">
       
   641 <span id="pyams-utils-html-module"></span><h2>pyams_utils.html module<a class="headerlink" href="#module-pyams_utils.html" title="Permalink to this headline">¶</a></h2>
       
   642 <dl class="class">
       
   643 <dt id="pyams_utils.html.MyHTMLParser">
       
   644 <em class="property">class </em><code class="descclassname">pyams_utils.html.</code><code class="descname">MyHTMLParser</code><span class="sig-paren">(</span><em>strict=&lt;object object&gt;</em>, <em>*</em>, <em>convert_charrefs=&lt;object object&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser" title="Permalink to this definition">¶</a></dt>
       
   645 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">html.parser.HTMLParser</span></code></p>
       
   646 <p>HTML parser</p>
       
   647 <dl class="attribute">
       
   648 <dt id="pyams_utils.html.MyHTMLParser.charrefs">
       
   649 <code class="descname">charrefs</code><em class="property"> = {34: '&quot;', 38: '&amp;', 39: &quot;'&quot;, 60: '&lt;', 62: '&gt;', 192: 'À', 193: 'A', 194: 'Â', 195: 'A', 196: 'Ä', 197: 'A', 198: 'AE', 199: 'Ç', 200: 'È', 201: 'É', 202: 'Ê', 203: 'Ë', 204: 'I', 205: 'I', 206: 'Î', 207: 'Ï', 208: 'D', 209: 'N', 210: 'O', 211: 'O', 212: 'Ô', 213: 'O', 214: 'Ö', 215: 'x', 216: 'O', 217: 'Ù', 218: 'U', 219: 'Û', 220: 'Ü', 221: 'Y', 222: 'T', 223: 'sz', 224: 'à', 225: 'a', 226: 'â', 227: 'a', 228: 'ä', 229: 'a', 230: 'ae', 231: 'ç', 232: 'è', 233: 'é', 234: 'ê', 235: 'ë', 236: 'i', 237: 'i', 238: 'î', 239: 'ï', 240: 'e', 241: 'n', 242: 'o', 243: 'o', 244: 'ô', 245: 'o', 246: 'ö', 248: 'o', 249: 'ù', 250: 'u', 251: 'û', 252: 'ü', 253: 'y', 255: 'ÿ'}</em><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.charrefs" title="Permalink to this definition">¶</a></dt>
       
   650 <dd></dd></dl>
       
   651 
       
   652 <dl class="attribute">
       
   653 <dt id="pyams_utils.html.MyHTMLParser.data">
       
   654 <code class="descname">data</code><em class="property"> = ''</em><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.data" title="Permalink to this definition">¶</a></dt>
       
   655 <dd></dd></dl>
       
   656 
       
   657 <dl class="attribute">
       
   658 <dt id="pyams_utils.html.MyHTMLParser.entitydefs">
       
   659 <code class="descname">entitydefs</code><em class="property"> = {'ecirc': 'ê', 'aring': 'a', 'Aring': 'A', 'thorn': 't', 'agrave': 'à', 'Ograve': 'O', 'ocirc': 'ô', 'Eacute': 'È', 'eacute': 'é', 'atilde': 'a', 'iuml': 'ï', 'aelig': 'ae', 'igrave': 'i', 'Auml': 'Ä', 'Uuml': 'Ü', 'ucirc': 'û', 'ugrave': 'ù', 'iacute': 'i', 'ograve': 'o', 'oacute': 'o', 'Euml': 'Ë', 'apos': &quot;'&quot;, 'Ouml': 'Ö', 'aacute': 'a', 'Ccedil': 'Ç', 'Oslash': 'O', 'egrave': 'è', 'Uacute': 'U', 'uacute': 'u', 'Igrave': 'I', 'Agrave': 'À', 'Iuml': 'I', 'Otilde': 'O', 'Yacute': 'Y', 'ntilde': 'n', 'Ugrave': 'Ù', 'Ucirc': 'Û', 'icirc': 'î', 'Ecirc': 'Ê', 'Ntilde': 'N', 'Egrave': 'É', 'nbsp': ' ', 'quot': '&quot;', 'oslash': 'o', 'ouml': 'ö', 'yacute': 'y', 'uuml': 'ü', 'yuml': 'ÿ', 'Aacute': 'A', 'Icirc': 'I', 'euml': 'ë', 'otilde': 'o', 'auml': 'ä', 'ccedil': 'ç', 'Oacute': 'O', 'lt': '&lt;', 'amp': '&amp;', 'Iacute': 'I', 'Ocirc': 'Ô', 'gt': '&gt;', 'Atilde': 'A', 'acirc': 'â', 'Acirc': 'Â', 'THORN': 'T', 'AElig': 'AE'}</em><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.entitydefs" title="Permalink to this definition">¶</a></dt>
       
   660 <dd></dd></dl>
       
   661 
       
   662 <dl class="method">
       
   663 <dt id="pyams_utils.html.MyHTMLParser.handle_charref">
       
   664 <code class="descname">handle_charref</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.handle_charref" title="Permalink to this definition">¶</a></dt>
       
   665 <dd></dd></dl>
       
   666 
       
   667 <dl class="method">
       
   668 <dt id="pyams_utils.html.MyHTMLParser.handle_data">
       
   669 <code class="descname">handle_data</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.handle_data" title="Permalink to this definition">¶</a></dt>
       
   670 <dd></dd></dl>
       
   671 
       
   672 <dl class="method">
       
   673 <dt id="pyams_utils.html.MyHTMLParser.handle_endtag">
       
   674 <code class="descname">handle_endtag</code><span class="sig-paren">(</span><em>tag</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.handle_endtag" title="Permalink to this definition">¶</a></dt>
       
   675 <dd></dd></dl>
       
   676 
       
   677 <dl class="method">
       
   678 <dt id="pyams_utils.html.MyHTMLParser.handle_entityref">
       
   679 <code class="descname">handle_entityref</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.handle_entityref" title="Permalink to this definition">¶</a></dt>
       
   680 <dd></dd></dl>
       
   681 
       
   682 <dl class="method">
       
   683 <dt id="pyams_utils.html.MyHTMLParser.handle_starttag">
       
   684 <code class="descname">handle_starttag</code><span class="sig-paren">(</span><em>tag</em>, <em>attrs</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.MyHTMLParser.handle_starttag" title="Permalink to this definition">¶</a></dt>
       
   685 <dd></dd></dl>
       
   686 
       
   687 </dd></dl>
       
   688 
       
   689 <dl class="function">
       
   690 <dt id="pyams_utils.html.html_to_text">
       
   691 <code class="descclassname">pyams_utils.html.</code><code class="descname">html_to_text</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.html.html_to_text" title="Permalink to this definition">¶</a></dt>
       
   692 <dd><p>Utility function to extract text content from HTML</p>
       
   693 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.html</span> <span class="k">import</span> <span class="n">html_to_text</span>
       
   694 <span class="gp">&gt;&gt;&gt; </span><span class="n">html</span> <span class="o">=</span> <span class="s">&#39;&#39;&#39;&lt;p&gt;This is a HTML text part.&lt;/p&gt;&#39;&#39;&#39;</span>
       
   695 <span class="gp">&gt;&gt;&gt; </span><span class="n">html_to_text</span><span class="p">(</span><span class="n">html</span><span class="p">)</span>
       
   696 <span class="go">&#39;This is a HTML text part.\n&#39;</span>
       
   697 </pre></div>
       
   698 </div>
       
   699 <p>HTML parser should handle entities correctly:</p>
       
   700 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">html</span> <span class="o">=</span> <span class="s">&#39;&#39;&#39;&lt;div&gt;&lt;p&gt;Header&lt;/p&gt;&lt;p&gt;This is an &amp;lt;&amp;nbsp;&amp;#242;&amp;nbsp;&amp;gt; entity.&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&#39;&#39;&#39;</span>
       
   701 <span class="gp">&gt;&gt;&gt; </span><span class="n">html_to_text</span><span class="p">(</span><span class="n">html</span><span class="p">)</span>
       
   702 <span class="go">&#39;Header\nThis is an &lt; o &gt; entity.\n\n&#39;</span>
       
   703 </pre></div>
       
   704 </div>
       
   705 </dd></dl>
       
   706 
       
   707 </div>
       
   708 <div class="section" id="module-pyams_utils.i18n">
       
   709 <span id="pyams-utils-i18n-module"></span><h2>pyams_utils.i18n module<a class="headerlink" href="#module-pyams_utils.i18n" title="Permalink to this headline">¶</a></h2>
       
   710 <dl class="function">
       
   711 <dt id="pyams_utils.i18n.get_browser_language">
       
   712 <code class="descclassname">pyams_utils.i18n.</code><code class="descname">get_browser_language</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.i18n.get_browser_language" title="Permalink to this definition">¶</a></dt>
       
   713 <dd><p>Custom locale negotiator</p>
       
   714 <p>Copied from zope.publisher code</p>
       
   715 </dd></dl>
       
   716 
       
   717 <dl class="function">
       
   718 <dt id="pyams_utils.i18n.normalize_lang">
       
   719 <code class="descclassname">pyams_utils.i18n.</code><code class="descname">normalize_lang</code><span class="sig-paren">(</span><em>lang</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.i18n.normalize_lang" title="Permalink to this definition">¶</a></dt>
       
   720 <dd></dd></dl>
       
   721 
       
   722 </div>
       
   723 <div class="section" id="module-pyams_utils.include">
       
   724 <span id="pyams-utils-include-module"></span><h2>pyams_utils.include module<a class="headerlink" href="#module-pyams_utils.include" title="Permalink to this headline">¶</a></h2>
       
   725 <dl class="function">
       
   726 <dt id="pyams_utils.include.include_package">
       
   727 <code class="descclassname">pyams_utils.include.</code><code class="descname">include_package</code><span class="sig-paren">(</span><em>config</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.include.include_package" title="Permalink to this definition">¶</a></dt>
       
   728 <dd><p>Pyramid package include</p>
       
   729 </dd></dl>
       
   730 
       
   731 </div>
       
   732 <div class="section" id="module-pyams_utils.intids">
       
   733 <span id="pyams-utils-intids-module"></span><h2>pyams_utils.intids module<a class="headerlink" href="#module-pyams_utils.intids" title="Permalink to this headline">¶</a></h2>
       
   734 <dl class="class">
       
   735 <dt id="pyams_utils.intids.UniqueIdAdapter">
       
   736 <em class="property">class </em><code class="descclassname">pyams_utils.intids.</code><code class="descname">UniqueIdAdapter</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.intids.UniqueIdAdapter" title="Permalink to this definition">¶</a></dt>
       
   737 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
   738 <p>Object unique ID adapter</p>
       
   739 <p>This adapter is based on a registered IIntIds utility to get a unique ID
       
   740 for any persistent object.</p>
       
   741 <dl class="attribute">
       
   742 <dt id="pyams_utils.intids.UniqueIdAdapter.oid">
       
   743 <code class="descname">oid</code><a class="headerlink" href="#pyams_utils.intids.UniqueIdAdapter.oid" title="Permalink to this definition">¶</a></dt>
       
   744 <dd><p>Get context ID in hexadecimal form</p>
       
   745 </dd></dl>
       
   746 
       
   747 </dd></dl>
       
   748 
       
   749 <dl class="function">
       
   750 <dt id="pyams_utils.intids.handle_added_object">
       
   751 <code class="descclassname">pyams_utils.intids.</code><code class="descname">handle_added_object</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.intids.handle_added_object" title="Permalink to this definition">¶</a></dt>
       
   752 <dd><p>Notify IntId utility for added objects</p>
       
   753 <p>This subscriber is used for all persistent objects to be registered
       
   754 in all locally registered IIntIds utilities.</p>
       
   755 </dd></dl>
       
   756 
       
   757 <dl class="function">
       
   758 <dt id="pyams_utils.intids.handle_intid_event">
       
   759 <code class="descclassname">pyams_utils.intids.</code><code class="descname">handle_intid_event</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.intids.handle_intid_event" title="Permalink to this definition">¶</a></dt>
       
   760 <dd><p>Event subscriber used to dispatch all IIntIdEvent events using Pyramid events subscribers to matching
       
   761 subscribers using Zope events</p>
       
   762 </dd></dl>
       
   763 
       
   764 <dl class="function">
       
   765 <dt id="pyams_utils.intids.handle_removed_object">
       
   766 <code class="descclassname">pyams_utils.intids.</code><code class="descname">handle_removed_object</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.intids.handle_removed_object" title="Permalink to this definition">¶</a></dt>
       
   767 <dd><p>Notify IntId utility for removed objects</p>
       
   768 <p>This subscriber is used for all persistent objects to be unregistered
       
   769 from all locally registered IIntIds utilities.</p>
       
   770 </dd></dl>
       
   771 
       
   772 </div>
       
   773 <div class="section" id="module-pyams_utils.list">
       
   774 <span id="pyams-utils-list-module"></span><h2>pyams_utils.list module<a class="headerlink" href="#module-pyams_utils.list" title="Permalink to this headline">¶</a></h2>
       
   775 <dl class="function">
       
   776 <dt id="pyams_utils.list.unique">
       
   777 <code class="descclassname">pyams_utils.list.</code><code class="descname">unique</code><span class="sig-paren">(</span><em>seq</em>, <em>idfun=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.list.unique" title="Permalink to this definition">¶</a></dt>
       
   778 <dd><p>Extract unique values from list, preserving order</p>
       
   779 <table class="docutils field-list" frame="void" rules="none">
       
   780 <col class="field-name" />
       
   781 <col class="field-body" />
       
   782 <tbody valign="top">
       
   783 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
   784 <li><strong>seq</strong> (<a class="reference internal" href="#module-pyams_utils.list" title="pyams_utils.list"><em>list</em></a>) &#8211; input list</li>
       
   785 <li><strong>idfun</strong> (<em>callable</em>) &#8211; an identity function which is used to get &#8216;identity&#8217; value of each element
       
   786 in the list</li>
       
   787 </ul>
       
   788 </td>
       
   789 </tr>
       
   790 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">list; a new list containing only unique elements of the original list in their initial order.
       
   791 Original list is not modified.</p>
       
   792 </td>
       
   793 </tr>
       
   794 </tbody>
       
   795 </table>
       
   796 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.list</span> <span class="k">import</span> <span class="n">unique</span>
       
   797 <span class="gp">&gt;&gt;&gt; </span><span class="n">mylist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
       
   798 <span class="gp">&gt;&gt;&gt; </span><span class="n">unique</span><span class="p">(</span><span class="n">mylist</span><span class="p">)</span>
       
   799 <span class="go">[1, 2, 3]</span>
       
   800 </pre></div>
       
   801 </div>
       
   802 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">mylist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
       
   803 <span class="gp">&gt;&gt;&gt; </span><span class="n">unique</span><span class="p">(</span><span class="n">mylist</span><span class="p">)</span>
       
   804 <span class="go">[3, 2, 1, 4]</span>
       
   805 </pre></div>
       
   806 </div>
       
   807 <p>You can also set an &#8216;id&#8217; function applied on each element:</p>
       
   808 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">mylist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s">&#39;2&#39;</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
       
   809 <span class="gp">&gt;&gt;&gt; </span><span class="n">unique</span><span class="p">(</span><span class="n">mylist</span><span class="p">,</span> <span class="n">idfun</span><span class="o">=</span><span class="nb">str</span><span class="p">)</span>
       
   810 <span class="go">[1, 2, 3, 4]</span>
       
   811 </pre></div>
       
   812 </div>
       
   813 </dd></dl>
       
   814 
       
   815 </div>
       
   816 <div class="section" id="module-pyams_utils.lock">
       
   817 <span id="pyams-utils-lock-module"></span><h2>pyams_utils.lock module<a class="headerlink" href="#module-pyams_utils.lock" title="Permalink to this headline">¶</a></h2>
       
   818 <dl class="class">
       
   819 <dt id="pyams_utils.lock.CacheLock">
       
   820 <em class="property">class </em><code class="descclassname">pyams_utils.lock.</code><code class="descname">CacheLock</code><span class="sig-paren">(</span><em>name</em>, <em>wait=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.lock.CacheLock" title="Permalink to this definition">¶</a></dt>
       
   821 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   822 <p>Beaker based lock</p>
       
   823 <p>This lock can be used when you need to get a lot across several processes or even computers.
       
   824 The lock relies on a shared value stored into a shared Beaker cache.</p>
       
   825 <table class="docutils field-list" frame="void" rules="none">
       
   826 <col class="field-name" />
       
   827 <col class="field-body" />
       
   828 <tbody valign="top">
       
   829 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
   830 <li><strong>name</strong> (<em>str</em>) &#8211; name of the lock to use as shared key</li>
       
   831 <li><strong>wait</strong> (<em>boolean</em>) &#8211; if <em>False</em>, a <em>LockException</em> is raised if lock can&#8217;t be taken; otherwise,
       
   832 application waits until lock is released</li>
       
   833 </ul>
       
   834 </td>
       
   835 </tr>
       
   836 </tbody>
       
   837 </table>
       
   838 <p>Lock can be used as a context manager.</p>
       
   839 </dd></dl>
       
   840 
       
   841 <dl class="exception">
       
   842 <dt id="pyams_utils.lock.LockException">
       
   843 <em class="property">exception </em><code class="descclassname">pyams_utils.lock.</code><code class="descname">LockException</code><a class="headerlink" href="#pyams_utils.lock.LockException" title="Permalink to this definition">¶</a></dt>
       
   844 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">Exception</span></code></p>
       
   845 <p>Cache lock exception</p>
       
   846 </dd></dl>
       
   847 
       
   848 <dl class="function">
       
   849 <dt id="pyams_utils.lock.get_locks_cache">
       
   850 <code class="descclassname">pyams_utils.lock.</code><code class="descname">get_locks_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.lock.get_locks_cache" title="Permalink to this definition">¶</a></dt>
       
   851 <dd><p>Get locks shared cache</p>
       
   852 </dd></dl>
       
   853 
       
   854 <dl class="function">
       
   855 <dt id="pyams_utils.lock.locked">
       
   856 <code class="descclassname">pyams_utils.lock.</code><code class="descname">locked</code><span class="sig-paren">(</span><em>name</em>, <em>wait=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.lock.locked" title="Permalink to this definition">¶</a></dt>
       
   857 <dd><p>Locked function decorator</p>
       
   858 <p>Can be used with any function or method which requires a global shared lock.</p>
       
   859 <table class="docutils field-list" frame="void" rules="none">
       
   860 <col class="field-name" />
       
   861 <col class="field-body" />
       
   862 <tbody valign="top">
       
   863 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
   864 <li><strong>name</strong> (<em>str</em>) &#8211; name of the lock to use as shared key</li>
       
   865 <li><strong>wait</strong> (<em>boolean</em>) &#8211; if <em>False</em>, a <em>LockException</em> is raised if lock can&#8217;t be taken; otherwise,
       
   866 application waits until lock is released</li>
       
   867 </ul>
       
   868 </td>
       
   869 </tr>
       
   870 </tbody>
       
   871 </table>
       
   872 </dd></dl>
       
   873 
       
   874 </div>
       
   875 <div class="section" id="module-pyams_utils.progress">
       
   876 <span id="pyams-utils-progress-module"></span><h2>pyams_utils.progress module<a class="headerlink" href="#module-pyams_utils.progress" title="Permalink to this headline">¶</a></h2>
       
   877 <dl class="function">
       
   878 <dt id="pyams_utils.progress.get_progress_cache">
       
   879 <code class="descclassname">pyams_utils.progress.</code><code class="descname">get_progress_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.progress.get_progress_cache" title="Permalink to this definition">¶</a></dt>
       
   880 <dd><p>Get cache storing tasks progress</p>
       
   881 </dd></dl>
       
   882 
       
   883 <dl class="function">
       
   884 <dt id="pyams_utils.progress.get_progress_status_view">
       
   885 <code class="descclassname">pyams_utils.progress.</code><code class="descname">get_progress_status_view</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.progress.get_progress_status_view" title="Permalink to this definition">¶</a></dt>
       
   886 <dd><p>Get progress status of a given task</p>
       
   887 <p>Each submitted task is identified by an ID defined when the task is created</p>
       
   888 </dd></dl>
       
   889 
       
   890 <dl class="function">
       
   891 <dt id="pyams_utils.progress.get_running_tasks">
       
   892 <code class="descclassname">pyams_utils.progress.</code><code class="descname">get_running_tasks</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.progress.get_running_tasks" title="Permalink to this definition">¶</a></dt>
       
   893 <dd><p>Get list of running tasks</p>
       
   894 </dd></dl>
       
   895 
       
   896 <dl class="function">
       
   897 <dt id="pyams_utils.progress.get_tasks_cache">
       
   898 <code class="descclassname">pyams_utils.progress.</code><code class="descname">get_tasks_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.progress.get_tasks_cache" title="Permalink to this definition">¶</a></dt>
       
   899 <dd><p>Get cache storing tasks list</p>
       
   900 </dd></dl>
       
   901 
       
   902 <dl class="function">
       
   903 <dt id="pyams_utils.progress.set_running_tasks">
       
   904 <code class="descclassname">pyams_utils.progress.</code><code class="descname">set_running_tasks</code><span class="sig-paren">(</span><em>tasks</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.progress.set_running_tasks" title="Permalink to this definition">¶</a></dt>
       
   905 <dd><p>Update list of running tasks</p>
       
   906 </dd></dl>
       
   907 
       
   908 </div>
       
   909 <div class="section" id="module-pyams_utils.property">
       
   910 <span id="pyams-utils-property-module"></span><h2>pyams_utils.property module<a class="headerlink" href="#module-pyams_utils.property" title="Permalink to this headline">¶</a></h2>
       
   911 <dl class="class">
       
   912 <dt id="pyams_utils.property.DocFieldProperty">
       
   913 <em class="property">class </em><code class="descclassname">pyams_utils.property.</code><code class="descname">DocFieldProperty</code><span class="sig-paren">(</span><em>field</em>, <em>name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.DocFieldProperty" title="Permalink to this definition">¶</a></dt>
       
   914 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema.fieldproperty.FieldProperty</span></code></p>
       
   915 </dd></dl>
       
   916 
       
   917 <dl class="class">
       
   918 <dt id="pyams_utils.property.cached">
       
   919 <em class="property">class </em><code class="descclassname">pyams_utils.property.</code><code class="descname">cached</code><span class="sig-paren">(</span><em>function</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.cached" title="Permalink to this definition">¶</a></dt>
       
   920 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   921 <p>Custom property decorator to define a property or function which is calculated only once</p>
       
   922 <p>When applied on a function, caching is based on input arguments</p>
       
   923 <dl class="method">
       
   924 <dt id="pyams_utils.property.cached.expire">
       
   925 <code class="descname">expire</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.cached.expire" title="Permalink to this definition">¶</a></dt>
       
   926 <dd></dd></dl>
       
   927 
       
   928 </dd></dl>
       
   929 
       
   930 <dl class="class">
       
   931 <dt id="pyams_utils.property.cached_property">
       
   932 <em class="property">class </em><code class="descclassname">pyams_utils.property.</code><code class="descname">cached_property</code><span class="sig-paren">(</span><em>fget</em>, <em>doc=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.cached_property" title="Permalink to this definition">¶</a></dt>
       
   933 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
   934 <p>A read-only property decorator that is only evaluated once.</p>
       
   935 <p>The value is cached on the object itself rather than the function or class; this should prevent
       
   936 memory leakage.</p>
       
   937 </dd></dl>
       
   938 
       
   939 <dl class="function">
       
   940 <dt id="pyams_utils.property.request_property">
       
   941 <code class="descclassname">pyams_utils.property.</code><code class="descname">request_property</code><span class="sig-paren">(</span><em>key</em>, <em>prefix=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.request_property" title="Permalink to this definition">¶</a></dt>
       
   942 <dd><p>Define a method decorator used to store result into current request&#8217;s annotations</p>
       
   943 <p>If not request is currently running, a new one is created.
       
   944 <cite>key</cite> is a required argument; if None, the key will be the method&#8217;s object</p>
       
   945 <table class="docutils field-list" frame="void" rules="none">
       
   946 <col class="field-name" />
       
   947 <col class="field-body" />
       
   948 <tbody valign="top">
       
   949 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
   950 <li><strong>key</strong> (<em>str</em>) &#8211; session&#8217;s value key; if <em>None</em>, the key will be the method&#8217;s object; if <em>key</em> is a callable
       
   951 object, it will be called to get the actual session key</li>
       
   952 <li><strong>prefix</strong> &#8211; str; prefix to use for session key; if <em>None</em>, the prefix will be the property name</li>
       
   953 </ul>
       
   954 </td>
       
   955 </tr>
       
   956 </tbody>
       
   957 </table>
       
   958 </dd></dl>
       
   959 
       
   960 <dl class="function">
       
   961 <dt id="pyams_utils.property.session_property">
       
   962 <code class="descclassname">pyams_utils.property.</code><code class="descname">session_property</code><span class="sig-paren">(</span><em>app</em>, <em>key=None</em>, <em>prefix=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.property.session_property" title="Permalink to this definition">¶</a></dt>
       
   963 <dd><p>Define a method decorator used to store result into request&#8217;s session</p>
       
   964 <p>If no request is currently running, a new one is created.</p>
       
   965 <table class="docutils field-list" frame="void" rules="none">
       
   966 <col class="field-name" />
       
   967 <col class="field-body" />
       
   968 <tbody valign="top">
       
   969 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
   970 <li><strong>app</strong> (<em>str</em>) &#8211; application identifier used to prefix session keys</li>
       
   971 <li><strong>key</strong> (<em>str</em>) &#8211; session&#8217;s value key; if <em>None</em>, the key will be the method&#8217;s object; if <em>key</em> is a callable
       
   972 object, il will be called to get the actual session key</li>
       
   973 <li><strong>prefix</strong> &#8211; str; prefix to use for session key; if <em>None</em>, the prefix will be the property name</li>
       
   974 </ul>
       
   975 </td>
       
   976 </tr>
       
   977 </tbody>
       
   978 </table>
       
   979 </dd></dl>
       
   980 
       
   981 </div>
       
   982 <div class="section" id="module-pyams_utils.registry">
       
   983 <span id="pyams-utils-registry-module"></span><h2>pyams_utils.registry module<a class="headerlink" href="#module-pyams_utils.registry" title="Permalink to this headline">¶</a></h2>
       
   984 <p>Local registry management package</p>
       
   985 <p>This package is used to manage <em>local registry</em>. A local registry is a <em>site management</em> component
       
   986 created automatically on application startup by PyAMS_utils package. It can be used to store and register
       
   987 components, mainly utilities which are created and configured dynamically by a site administrator; this can include
       
   988 SQLAlchemy engines, ZEO connections, and several PyAMS utilities like security manager, medias converter,
       
   989 tasks scheduler and many other ones.</p>
       
   990 <p>See <a class="reference internal" href="zca.html#zca"><span class="std std-ref">Managing ZCA with PyAMS</span></a> to get a brief introduction about using a local registry with PyAMS packages.</p>
       
   991 <dl class="class">
       
   992 <dt id="pyams_utils.registry.LocalRegistry">
       
   993 <em class="property">class </em><code class="descclassname">pyams_utils.registry.</code><code class="descname">LocalRegistry</code><a class="headerlink" href="#pyams_utils.registry.LocalRegistry" title="Permalink to this definition">¶</a></dt>
       
   994 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">_thread._local</span></code></p>
       
   995 <p>Local registry</p>
       
   996 <dl class="method">
       
   997 <dt id="pyams_utils.registry.LocalRegistry.get_registry">
       
   998 <code class="descname">get_registry</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.LocalRegistry.get_registry" title="Permalink to this definition">¶</a></dt>
       
   999 <dd></dd></dl>
       
  1000 
       
  1001 <dl class="method">
       
  1002 <dt id="pyams_utils.registry.LocalRegistry.set_registry">
       
  1003 <code class="descname">set_registry</code><span class="sig-paren">(</span><em>registry</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.LocalRegistry.set_registry" title="Permalink to this definition">¶</a></dt>
       
  1004 <dd></dd></dl>
       
  1005 
       
  1006 </dd></dl>
       
  1007 
       
  1008 <dl class="function">
       
  1009 <dt id="pyams_utils.registry.get_all_utilities_registered_for">
       
  1010 <code class="descclassname">pyams_utils.registry.</code><code class="descname">get_all_utilities_registered_for</code><span class="sig-paren">(</span><em>interface</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.get_all_utilities_registered_for" title="Permalink to this definition">¶</a></dt>
       
  1011 <dd><p>Get list of registered utilities for given interface</p>
       
  1012 <p>Do a registry lookup for matching utilities into local registry first, then on each registry
       
  1013 associated with current thread stack.</p>
       
  1014 </dd></dl>
       
  1015 
       
  1016 <dl class="function">
       
  1017 <dt id="pyams_utils.registry.get_local_registry">
       
  1018 <code class="descclassname">pyams_utils.registry.</code><code class="descname">get_local_registry</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.get_local_registry" title="Permalink to this definition">¶</a></dt>
       
  1019 <dd><p>Get local registry</p>
       
  1020 </dd></dl>
       
  1021 
       
  1022 <dl class="function">
       
  1023 <dt id="pyams_utils.registry.get_registries">
       
  1024 <code class="descclassname">pyams_utils.registry.</code><code class="descname">get_registries</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.get_registries" title="Permalink to this definition">¶</a></dt>
       
  1025 <dd><p>Iterator on components registries</p>
       
  1026 <p>Returns an iterator on current local registry (if any) and registries associated
       
  1027 in current thread stack.</p>
       
  1028 </dd></dl>
       
  1029 
       
  1030 <dl class="function">
       
  1031 <dt id="pyams_utils.registry.get_utilities_for">
       
  1032 <code class="descclassname">pyams_utils.registry.</code><code class="descname">get_utilities_for</code><span class="sig-paren">(</span><em>interface</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.get_utilities_for" title="Permalink to this definition">¶</a></dt>
       
  1033 <dd><p>Get utilities registered with given interface as (name, util) tuples iterator</p>
       
  1034 <p>Do a registry lookup for matching utilities into local registry first, then on each registry
       
  1035 associated with current thread stack.</p>
       
  1036 </dd></dl>
       
  1037 
       
  1038 <dl class="function">
       
  1039 <dt id="pyams_utils.registry.get_utility">
       
  1040 <code class="descclassname">pyams_utils.registry.</code><code class="descname">get_utility</code><span class="sig-paren">(</span><em>provided</em>, <em>name=''</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.get_utility" title="Permalink to this definition">¶</a></dt>
       
  1041 <dd><p>Get utility registered with given interface</p>
       
  1042 <p>Do a registry lookup for given utility into local registry first, then on each registry
       
  1043 associated with current thread stack.</p>
       
  1044 <table class="docutils field-list" frame="void" rules="none">
       
  1045 <col class="field-name" />
       
  1046 <col class="field-body" />
       
  1047 <tbody valign="top">
       
  1048 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1049 <li><strong>provided</strong> (<em>Interface</em>) &#8211; the requested interface</li>
       
  1050 <li><strong>name</strong> (<em>str</em>) &#8211; name of the requested utility</li>
       
  1051 </ul>
       
  1052 </td>
       
  1053 </tr>
       
  1054 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">object; the requested object. A <em>ComponentLookupError</em> is raised if the utility
       
  1055 can&#8217;t be found.</p>
       
  1056 </td>
       
  1057 </tr>
       
  1058 </tbody>
       
  1059 </table>
       
  1060 </dd></dl>
       
  1061 
       
  1062 <dl class="function">
       
  1063 <dt id="pyams_utils.registry.handle_new_request">
       
  1064 <code class="descclassname">pyams_utils.registry.</code><code class="descname">handle_new_request</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.handle_new_request" title="Permalink to this definition">¶</a></dt>
       
  1065 <dd><p>New request event subscriber</p>
       
  1066 <p>Is used to initialize local registry to None for any new request</p>
       
  1067 </dd></dl>
       
  1068 
       
  1069 <dl class="function">
       
  1070 <dt id="pyams_utils.registry.handle_site_before_traverse">
       
  1071 <code class="descclassname">pyams_utils.registry.</code><code class="descname">handle_site_before_traverse</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.handle_site_before_traverse" title="Permalink to this definition">¶</a></dt>
       
  1072 <dd><p>Before traverse event subscriber</p>
       
  1073 <p>Define site&#8217;s local registry when an object implementing ISite is traversed</p>
       
  1074 </dd></dl>
       
  1075 
       
  1076 <dl class="function">
       
  1077 <dt id="pyams_utils.registry.query_utility">
       
  1078 <code class="descclassname">pyams_utils.registry.</code><code class="descname">query_utility</code><span class="sig-paren">(</span><em>provided</em>, <em>name=''</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.query_utility" title="Permalink to this definition">¶</a></dt>
       
  1079 <dd><p>Query utility registered with given interface</p>
       
  1080 <p>Do a registry lookup for given utility into local registry first, then on each registry
       
  1081 associated with current thread stack.</p>
       
  1082 <table class="docutils field-list" frame="void" rules="none">
       
  1083 <col class="field-name" />
       
  1084 <col class="field-body" />
       
  1085 <tbody valign="top">
       
  1086 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1087 <li><strong>provided</strong> (<em>Interface</em>) &#8211; the requested interface</li>
       
  1088 <li><strong>name</strong> (<em>str</em>) &#8211; name of the requested utility</li>
       
  1089 <li><strong>default</strong> (<em>object</em>) &#8211; the default object returned if the requested utility can&#8217;t be found</li>
       
  1090 </ul>
       
  1091 </td>
       
  1092 </tr>
       
  1093 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">object; the requested object, or <em>default</em> if it can&#8217;t be found</p>
       
  1094 </td>
       
  1095 </tr>
       
  1096 </tbody>
       
  1097 </table>
       
  1098 </dd></dl>
       
  1099 
       
  1100 <dl class="function">
       
  1101 <dt id="pyams_utils.registry.registered_utilities">
       
  1102 <code class="descclassname">pyams_utils.registry.</code><code class="descname">registered_utilities</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.registered_utilities" title="Permalink to this definition">¶</a></dt>
       
  1103 <dd><p>Get utilities registrations as generator</p>
       
  1104 <p>Iterates over utilities defined in all registries, starting with local ones.</p>
       
  1105 </dd></dl>
       
  1106 
       
  1107 <dl class="function">
       
  1108 <dt id="pyams_utils.registry.set_local_registry">
       
  1109 <code class="descclassname">pyams_utils.registry.</code><code class="descname">set_local_registry</code><span class="sig-paren">(</span><em>registry</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.set_local_registry" title="Permalink to this definition">¶</a></dt>
       
  1110 <dd><p>Define local registry</p>
       
  1111 </dd></dl>
       
  1112 
       
  1113 <dl class="class">
       
  1114 <dt id="pyams_utils.registry.utility_config">
       
  1115 <em class="property">class </em><code class="descclassname">pyams_utils.registry.</code><code class="descname">utility_config</code><span class="sig-paren">(</span><em>**settings</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.registry.utility_config" title="Permalink to this definition">¶</a></dt>
       
  1116 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
  1117 <p>Function or class decorator to register a utility in the global registry</p>
       
  1118 <table class="docutils field-list" frame="void" rules="none">
       
  1119 <col class="field-name" />
       
  1120 <col class="field-body" />
       
  1121 <tbody valign="top">
       
  1122 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1123 <li><strong>name</strong> (<em>str</em>) &#8211; default=&#8217;&#8216;; name under which the utility is registered</li>
       
  1124 <li><strong>provides</strong> (<em>Interface</em>) &#8211; the interface for which the utility is registered</li>
       
  1125 </ul>
       
  1126 </td>
       
  1127 </tr>
       
  1128 </tbody>
       
  1129 </table>
       
  1130 <p>Please note that a single utility can be registered several times (using several annotations).</p>
       
  1131 <dl class="attribute">
       
  1132 <dt id="pyams_utils.registry.utility_config.venusian">
       
  1133 <code class="descname">venusian</code><em class="property"> = &lt;module 'venusian' from '/var/local/env/pyams/eggs/venusian-1.0-py3.4.egg/venusian/__init__.py'&gt;</em><a class="headerlink" href="#pyams_utils.registry.utility_config.venusian" title="Permalink to this definition">¶</a></dt>
       
  1134 <dd></dd></dl>
       
  1135 
       
  1136 </dd></dl>
       
  1137 
       
  1138 </div>
       
  1139 <div class="section" id="module-pyams_utils.request">
       
  1140 <span id="pyams-utils-request-module"></span><h2>pyams_utils.request module<a class="headerlink" href="#module-pyams_utils.request" title="Permalink to this headline">¶</a></h2>
       
  1141 <dl class="function">
       
  1142 <dt id="pyams_utils.request.check_request">
       
  1143 <code class="descclassname">pyams_utils.request.</code><code class="descname">check_request</code><span class="sig-paren">(</span><em>path='/'</em>, <em>environ=None</em>, <em>base_url=None</em>, <em>headers=None</em>, <em>POST=None</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.check_request" title="Permalink to this definition">¶</a></dt>
       
  1144 <dd><p>Get current request, or create a new blank one if missing</p>
       
  1145 </dd></dl>
       
  1146 
       
  1147 <dl class="function">
       
  1148 <dt id="pyams_utils.request.get_annotations">
       
  1149 <code class="descclassname">pyams_utils.request.</code><code class="descname">get_annotations</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.get_annotations" title="Permalink to this definition">¶</a></dt>
       
  1150 <dd><p>Define &#8216;annotations&#8217; request property</p>
       
  1151 <p>This function is automatically defined as a custom request method on package include.</p>
       
  1152 </dd></dl>
       
  1153 
       
  1154 <dl class="function">
       
  1155 <dt id="pyams_utils.request.get_debug">
       
  1156 <code class="descclassname">pyams_utils.request.</code><code class="descname">get_debug</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.get_debug" title="Permalink to this definition">¶</a></dt>
       
  1157 <dd><p>Define &#8216;debug&#8217; request property</p>
       
  1158 <p>This function is automatically defined as a custom request method on package include.</p>
       
  1159 </dd></dl>
       
  1160 
       
  1161 <dl class="function">
       
  1162 <dt id="pyams_utils.request.get_request">
       
  1163 <code class="descclassname">pyams_utils.request.</code><code class="descname">get_request</code><span class="sig-paren">(</span><em>raise_exception=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.get_request" title="Permalink to this definition">¶</a></dt>
       
  1164 <dd><p>Get current request</p>
       
  1165 <p>Raises a NoInteraction exception if there is no active request.</p>
       
  1166 </dd></dl>
       
  1167 
       
  1168 <dl class="function">
       
  1169 <dt id="pyams_utils.request.get_request_data">
       
  1170 <code class="descclassname">pyams_utils.request.</code><code class="descname">get_request_data</code><span class="sig-paren">(</span><em>request</em>, <em>key</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.get_request_data" title="Permalink to this definition">¶</a></dt>
       
  1171 <dd><p>Get data associated with request</p>
       
  1172 <table class="docutils field-list" frame="void" rules="none">
       
  1173 <col class="field-name" />
       
  1174 <col class="field-body" />
       
  1175 <tbody valign="top">
       
  1176 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1177 <li><strong>request</strong> &#8211; the request containing requested data</li>
       
  1178 <li><strong>key</strong> (<em>str</em>) &#8211; request data annotation key</li>
       
  1179 <li><strong>default</strong> (<em>object</em>) &#8211; the default value when data is missing</li>
       
  1180 </ul>
       
  1181 </td>
       
  1182 </tr>
       
  1183 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the requested value, or <em>default</em></p>
       
  1184 </td>
       
  1185 </tr>
       
  1186 </tbody>
       
  1187 </table>
       
  1188 </dd></dl>
       
  1189 
       
  1190 <dl class="function">
       
  1191 <dt id="pyams_utils.request.query_request">
       
  1192 <code class="descclassname">pyams_utils.request.</code><code class="descname">query_request</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.query_request" title="Permalink to this definition">¶</a></dt>
       
  1193 <dd><p>Query current request</p>
       
  1194 <p>Returns None if there is no active request</p>
       
  1195 </dd></dl>
       
  1196 
       
  1197 <dl class="function">
       
  1198 <dt id="pyams_utils.request.set_request_data">
       
  1199 <code class="descclassname">pyams_utils.request.</code><code class="descname">set_request_data</code><span class="sig-paren">(</span><em>request</em>, <em>key</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.request.set_request_data" title="Permalink to this definition">¶</a></dt>
       
  1200 <dd><p>Associate data with request</p>
       
  1201 <table class="docutils field-list" frame="void" rules="none">
       
  1202 <col class="field-name" />
       
  1203 <col class="field-body" />
       
  1204 <tbody valign="top">
       
  1205 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1206 <li><strong>request</strong> &#8211; the request in which to set data</li>
       
  1207 <li><strong>key</strong> (<em>str</em>) &#8211; request data annotation key</li>
       
  1208 <li><strong>value</strong> (<em>object</em>) &#8211; the value to be set in request annotation</li>
       
  1209 </ul>
       
  1210 </td>
       
  1211 </tr>
       
  1212 </tbody>
       
  1213 </table>
       
  1214 </dd></dl>
       
  1215 
       
  1216 </div>
       
  1217 <div class="section" id="module-pyams_utils.schema">
       
  1218 <span id="pyams-utils-schema-module"></span><h2>pyams_utils.schema module<a class="headerlink" href="#module-pyams_utils.schema" title="Permalink to this headline">¶</a></h2>
       
  1219 <dl class="class">
       
  1220 <dt id="pyams_utils.schema.ColorField">
       
  1221 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">ColorField</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.ColorField" title="Permalink to this definition">¶</a></dt>
       
  1222 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._bootstrapfields.TextLine</span></code></p>
       
  1223 <p>Color field</p>
       
  1224 </dd></dl>
       
  1225 
       
  1226 <dl class="class">
       
  1227 <dt id="pyams_utils.schema.DatesRangeField">
       
  1228 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">DatesRangeField</code><span class="sig-paren">(</span><em>value_type=None</em>, <em>unique=False</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.DatesRangeField" title="Permalink to this definition">¶</a></dt>
       
  1229 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.Tuple</span></code></p>
       
  1230 <p>Dates range field</p>
       
  1231 </dd></dl>
       
  1232 
       
  1233 <dl class="class">
       
  1234 <dt id="pyams_utils.schema.DottedDecimalField">
       
  1235 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">DottedDecimalField</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.DottedDecimalField" title="Permalink to this definition">¶</a></dt>
       
  1236 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.Decimal</span></code></p>
       
  1237 <p>Dotted decimal field</p>
       
  1238 </dd></dl>
       
  1239 
       
  1240 <dl class="class">
       
  1241 <dt id="pyams_utils.schema.EncodedPassword">
       
  1242 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">EncodedPassword</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.EncodedPassword" title="Permalink to this definition">¶</a></dt>
       
  1243 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._bootstrapfields.Password</span></code></p>
       
  1244 <p>Encoded password field</p>
       
  1245 <dl class="method">
       
  1246 <dt id="pyams_utils.schema.EncodedPassword.constraint">
       
  1247 <code class="descname">constraint</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.EncodedPassword.constraint" title="Permalink to this definition">¶</a></dt>
       
  1248 <dd></dd></dl>
       
  1249 
       
  1250 <dl class="method">
       
  1251 <dt id="pyams_utils.schema.EncodedPassword.fromUnicode">
       
  1252 <code class="descname">fromUnicode</code><span class="sig-paren">(</span><em>str</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.EncodedPassword.fromUnicode" title="Permalink to this definition">¶</a></dt>
       
  1253 <dd></dd></dl>
       
  1254 
       
  1255 </dd></dl>
       
  1256 
       
  1257 <dl class="class">
       
  1258 <dt id="pyams_utils.schema.HTMLField">
       
  1259 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">HTMLField</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.HTMLField" title="Permalink to this definition">¶</a></dt>
       
  1260 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._bootstrapfields.Text</span></code></p>
       
  1261 <p>HTML field</p>
       
  1262 </dd></dl>
       
  1263 
       
  1264 <dl class="class">
       
  1265 <dt id="pyams_utils.schema.PersistentDict">
       
  1266 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">PersistentDict</code><span class="sig-paren">(</span><em>key_type=None</em>, <em>value_type=None</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.PersistentDict" title="Permalink to this definition">¶</a></dt>
       
  1267 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.Dict</span></code></p>
       
  1268 <p>Persistent mapping field</p>
       
  1269 </dd></dl>
       
  1270 
       
  1271 <dl class="class">
       
  1272 <dt id="pyams_utils.schema.PersistentList">
       
  1273 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">PersistentList</code><span class="sig-paren">(</span><em>value_type=None</em>, <em>unique=False</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.PersistentList" title="Permalink to this definition">¶</a></dt>
       
  1274 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.List</span></code></p>
       
  1275 <p>Persistent list field</p>
       
  1276 </dd></dl>
       
  1277 
       
  1278 <dl class="class">
       
  1279 <dt id="pyams_utils.schema.TextLineListField">
       
  1280 <em class="property">class </em><code class="descclassname">pyams_utils.schema.</code><code class="descname">TextLineListField</code><span class="sig-paren">(</span><em>value_type=None</em>, <em>unique=False</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.schema.TextLineListField" title="Permalink to this definition">¶</a></dt>
       
  1281 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema._field.List</span></code></p>
       
  1282 <p>TextLine list field</p>
       
  1283 </dd></dl>
       
  1284 
       
  1285 </div>
       
  1286 <div class="section" id="module-pyams_utils.session">
       
  1287 <span id="pyams-utils-session-module"></span><h2>pyams_utils.session module<a class="headerlink" href="#module-pyams_utils.session" title="Permalink to this headline">¶</a></h2>
       
  1288 <dl class="function">
       
  1289 <dt id="pyams_utils.session.get_session_data">
       
  1290 <code class="descclassname">pyams_utils.session.</code><code class="descname">get_session_data</code><span class="sig-paren">(</span><em>request</em>, <em>app</em>, <em>key</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.session.get_session_data" title="Permalink to this definition">¶</a></dt>
       
  1291 <dd><p>Get data associated with current user session</p>
       
  1292 <p>PyAMS session management is based on <code class="xref py py-mod docutils literal"><span class="pre">Beaker</span></code> package session management.</p>
       
  1293 <table class="docutils field-list" frame="void" rules="none">
       
  1294 <col class="field-name" />
       
  1295 <col class="field-body" />
       
  1296 <tbody valign="top">
       
  1297 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1298 <li><strong>request</strong> &#8211; the request from which session is extracted</li>
       
  1299 <li><strong>app</strong> (<em>str</em>) &#8211; application name</li>
       
  1300 <li><strong>key</strong> (<em>str</em>) &#8211; session data key for given application</li>
       
  1301 <li><strong>default</strong> &#8211; object; requested session data, or <em>default</em> if it can&#8217;t be found</li>
       
  1302 </ul>
       
  1303 </td>
       
  1304 </tr>
       
  1305 </tbody>
       
  1306 </table>
       
  1307 <div class="highlight-python"><div class="highlight"><pre><span class="n">APPLICATION_KEY</span> <span class="o">=</span> <span class="s">&#39;MyApp&#39;</span>
       
  1308 <span class="n">SESSION_KEY</span> <span class="o">=</span> <span class="s">&#39;MyFunction&#39;</span>
       
  1309 
       
  1310 <span class="k">def</span> <span class="nf">my_function</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
       
  1311     <span class="k">return</span> <span class="n">get_session_data</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">APPLICATION_KEY</span><span class="p">,</span> <span class="n">SESSION_KEY</span><span class="p">)</span>
       
  1312 </pre></div>
       
  1313 </div>
       
  1314 </dd></dl>
       
  1315 
       
  1316 <dl class="function">
       
  1317 <dt id="pyams_utils.session.set_session_data">
       
  1318 <code class="descclassname">pyams_utils.session.</code><code class="descname">set_session_data</code><span class="sig-paren">(</span><em>request</em>, <em>app</em>, <em>key</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.session.set_session_data" title="Permalink to this definition">¶</a></dt>
       
  1319 <dd><p>Associate data with current user session</p>
       
  1320 <table class="docutils field-list" frame="void" rules="none">
       
  1321 <col class="field-name" />
       
  1322 <col class="field-body" />
       
  1323 <tbody valign="top">
       
  1324 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1325 <li><strong>request</strong> &#8211; the request from which session is extracted</li>
       
  1326 <li><strong>app</strong> (<em>str</em>) &#8211; application name</li>
       
  1327 <li><strong>key</strong> (<em>str</em>) &#8211; session data key for given application</li>
       
  1328 <li><strong>value</strong> (<em>object</em>) &#8211; any object that can be pickled can be stored into user session</li>
       
  1329 </ul>
       
  1330 </td>
       
  1331 </tr>
       
  1332 </tbody>
       
  1333 </table>
       
  1334 <div class="highlight-python"><div class="highlight"><pre><span class="n">APPLICATION_KEY</span> <span class="o">=</span> <span class="s">&#39;MyApp&#39;</span>
       
  1335 <span class="n">SESSION_KEY</span> <span class="o">=</span> <span class="s">&#39;MyFunction&#39;</span>
       
  1336 
       
  1337 <span class="k">def</span> <span class="nf">my_function</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
       
  1338     <span class="n">value</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;key1&#39;</span><span class="p">:</span> <span class="s">&#39;value1&#39;</span><span class="p">,</span> <span class="s">&#39;key2&#39;</span><span class="p">:</span> <span class="s">&#39;value2&#39;</span><span class="p">}</span>
       
  1339     <span class="n">set_session_data</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">APPLICATION_KEY</span><span class="p">,</span> <span class="n">SESSION_KEY</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
       
  1340 </pre></div>
       
  1341 </div>
       
  1342 </dd></dl>
       
  1343 
       
  1344 </div>
       
  1345 <div class="section" id="module-pyams_utils.site">
       
  1346 <span id="pyams-utils-site-module"></span><h2>pyams_utils.site module<a class="headerlink" href="#module-pyams_utils.site" title="Permalink to this headline">¶</a></h2>
       
  1347 <dl class="class">
       
  1348 <dt id="pyams_utils.site.BaseSiteRoot">
       
  1349 <em class="property">class </em><code class="descclassname">pyams_utils.site.</code><code class="descname">BaseSiteRoot</code><a class="headerlink" href="#pyams_utils.site.BaseSiteRoot" title="Permalink to this definition">¶</a></dt>
       
  1350 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.container.folder.Folder</span></code>, <code class="xref py py-class docutils literal"><span class="pre">zope.site.site.SiteManagerContainer</span></code></p>
       
  1351 <p>Default site root</p>
       
  1352 <p>A site root can be used as base application root in your ZODB.
       
  1353 It&#8217;s also site root responsibility to manage your local site manager.</p>
       
  1354 <p>BaseSiteRoot defines a basic ACL which gives all permissions to system administrator.</p>
       
  1355 <dl class="attribute">
       
  1356 <dt id="pyams_utils.site.BaseSiteRoot.config_klass">
       
  1357 <code class="descname">config_klass</code><em class="property"> = None</em><a class="headerlink" href="#pyams_utils.site.BaseSiteRoot.config_klass" title="Permalink to this definition">¶</a></dt>
       
  1358 <dd></dd></dl>
       
  1359 
       
  1360 </dd></dl>
       
  1361 
       
  1362 <dl class="class">
       
  1363 <dt id="pyams_utils.site.NewLocalSiteCreatedEvent">
       
  1364 <em class="property">class </em><code class="descclassname">pyams_utils.site.</code><code class="descname">NewLocalSiteCreatedEvent</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.NewLocalSiteCreatedEvent" title="Permalink to this definition">¶</a></dt>
       
  1365 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.interface.interfaces.ObjectEvent</span></code></p>
       
  1366 <p>New local site creation event</p>
       
  1367 </dd></dl>
       
  1368 
       
  1369 <dl class="class">
       
  1370 <dt id="pyams_utils.site.SiteRootEtcTraverser">
       
  1371 <em class="property">class </em><code class="descclassname">pyams_utils.site.</code><code class="descname">SiteRootEtcTraverser</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.SiteRootEtcTraverser" title="Permalink to this definition">¶</a></dt>
       
  1372 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
  1373 <p>Site root ++etc++ namespace traverser</p>
       
  1374 <p>Gives access to local site manager from <em>/++etc++site</em> URL</p>
       
  1375 <dl class="method">
       
  1376 <dt id="pyams_utils.site.SiteRootEtcTraverser.traverse">
       
  1377 <code class="descname">traverse</code><span class="sig-paren">(</span><em>name</em>, <em>furtherpath=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.SiteRootEtcTraverser.traverse" title="Permalink to this definition">¶</a></dt>
       
  1378 <dd></dd></dl>
       
  1379 
       
  1380 </dd></dl>
       
  1381 
       
  1382 <dl class="class">
       
  1383 <dt id="pyams_utils.site.SiteUpgradeEvent">
       
  1384 <em class="property">class </em><code class="descclassname">pyams_utils.site.</code><code class="descname">SiteUpgradeEvent</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.SiteUpgradeEvent" title="Permalink to this definition">¶</a></dt>
       
  1385 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.interface.interfaces.ObjectEvent</span></code></p>
       
  1386 <p>Site upgrade request event</p>
       
  1387 </dd></dl>
       
  1388 
       
  1389 <dl class="function">
       
  1390 <dt id="pyams_utils.site.check_required_utilities">
       
  1391 <code class="descclassname">pyams_utils.site.</code><code class="descname">check_required_utilities</code><span class="sig-paren">(</span><em>site</em>, <em>utilities</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.check_required_utilities" title="Permalink to this definition">¶</a></dt>
       
  1392 <dd><p>Utility function to check for required utilities</p>
       
  1393 <table class="docutils field-list" frame="void" rules="none">
       
  1394 <col class="field-name" />
       
  1395 <col class="field-body" />
       
  1396 <tbody valign="top">
       
  1397 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1398 <li><strong>site</strong> (<em>object</em>) &#8211; the site manager into which configuration may be checked</li>
       
  1399 <li><strong>utilities</strong> (<em>tuple</em>) &#8211; each element of the tuple is another tuple made of the utility interface,
       
  1400 the utility registration name, the utility factory and the object name when creating the utility, as in:</li>
       
  1401 </ul>
       
  1402 </td>
       
  1403 </tr>
       
  1404 </tbody>
       
  1405 </table>
       
  1406 <div class="highlight-python"><div class="highlight"><pre><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>
       
  1407                       <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>
       
  1408 </pre></div>
       
  1409 </div>
       
  1410 </dd></dl>
       
  1411 
       
  1412 <dl class="function">
       
  1413 <dt id="pyams_utils.site.site_factory">
       
  1414 <code class="descclassname">pyams_utils.site.</code><code class="descname">site_factory</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.site_factory" title="Permalink to this definition">¶</a></dt>
       
  1415 <dd><p>Application site factory</p>
       
  1416 <p>On application startup, this factory checks configuration to get application name and
       
  1417 load it from the ZODB; if the application can&#8217;t be found, configuration is scanned to
       
  1418 get application factory, create a new one and create a local site manager.</p>
       
  1419 </dd></dl>
       
  1420 
       
  1421 <dl class="function">
       
  1422 <dt id="pyams_utils.site.site_upgrade">
       
  1423 <code class="descclassname">pyams_utils.site.</code><code class="descname">site_upgrade</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.site.site_upgrade" title="Permalink to this definition">¶</a></dt>
       
  1424 <dd><p>Upgrade site when needed</p>
       
  1425 <p>This function is executed by <em>pyams_upgrade</em> console script.
       
  1426 Site generations are registered named utilities providing
       
  1427 <code class="xref py py-class docutils literal"><span class="pre">ISiteGenerations</span></code> interface.</p>
       
  1428 <p>Current site generations are stored into annotations for each generation adapter.</p>
       
  1429 </dd></dl>
       
  1430 
       
  1431 </div>
       
  1432 <div class="section" id="module-pyams_utils.size">
       
  1433 <span id="pyams-utils-size-module"></span><h2>pyams_utils.size module<a class="headerlink" href="#module-pyams_utils.size" title="Permalink to this headline">¶</a></h2>
       
  1434 <dl class="function">
       
  1435 <dt id="pyams_utils.size.get_human_size">
       
  1436 <code class="descclassname">pyams_utils.size.</code><code class="descname">get_human_size</code><span class="sig-paren">(</span><em>value</em>, <em>request=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.size.get_human_size" title="Permalink to this definition">¶</a></dt>
       
  1437 <dd><p>Convert given bytes value in human readable format</p>
       
  1438 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyramid.testing</span> <span class="k">import</span> <span class="n">DummyRequest</span>
       
  1439 <span class="gp">&gt;&gt;&gt; </span><span class="n">request</span> <span class="o">=</span> <span class="n">DummyRequest</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;_LOCALE_&#39;</span><span class="p">:</span> <span class="s">&#39;en&#39;</span><span class="p">})</span>
       
  1440 <span class="gp">&gt;&gt;&gt; </span><span class="n">request</span><span class="o">.</span><span class="n">locale_name</span>
       
  1441 <span class="go">&#39;en&#39;</span>
       
  1442 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.size</span> <span class="k">import</span> <span class="n">get_human_size</span>
       
  1443 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1444 <span class="go">&#39;256 bytes&#39;</span>
       
  1445 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">3678</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1446 <span class="go">&#39;3.6 Kb&#39;</span>
       
  1447 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">6785342</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1448 <span class="go">&#39;6.47 Mb&#39;</span>
       
  1449 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">3674815342</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1450 <span class="go">&#39;3.422 Gb&#39;</span>
       
  1451 <span class="gp">&gt;&gt;&gt; </span><span class="n">request</span> <span class="o">=</span> <span class="n">DummyRequest</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;_LOCALE_&#39;</span><span class="p">:</span> <span class="s">&#39;fr&#39;</span><span class="p">})</span>
       
  1452 <span class="gp">&gt;&gt;&gt; </span><span class="n">request</span><span class="o">.</span><span class="n">locale_name</span>
       
  1453 <span class="go">&#39;fr&#39;</span>
       
  1454 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1455 <span class="go">&#39;256 bytes&#39;</span>
       
  1456 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">3678</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1457 <span class="go">&#39;3,6 Kb&#39;</span>
       
  1458 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">6785342</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1459 <span class="go">&#39;6,47 Mb&#39;</span>
       
  1460 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_human_size</span><span class="p">(</span><span class="mi">3674815342</span><span class="p">,</span> <span class="n">request</span><span class="p">)</span>
       
  1461 <span class="go">&#39;3,422 Gb&#39;</span>
       
  1462 </pre></div>
       
  1463 </div>
       
  1464 </dd></dl>
       
  1465 
       
  1466 </div>
       
  1467 <div class="section" id="module-pyams_utils.tales">
       
  1468 <span id="pyams-utils-tales-module"></span><h2>pyams_utils.tales module<a class="headerlink" href="#module-pyams_utils.tales" title="Permalink to this headline">¶</a></h2>
       
  1469 <dl class="class">
       
  1470 <dt id="pyams_utils.tales.ContextExprMixin">
       
  1471 <em class="property">class </em><code class="descclassname">pyams_utils.tales.</code><code class="descname">ContextExprMixin</code><a class="headerlink" href="#pyams_utils.tales.ContextExprMixin" title="Permalink to this definition">¶</a></dt>
       
  1472 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
  1473 <p>Mixin-class for expression compilers</p>
       
  1474 <dl class="attribute">
       
  1475 <dt id="pyams_utils.tales.ContextExprMixin.transform">
       
  1476 <code class="descname">transform</code><em class="property"> = None</em><a class="headerlink" href="#pyams_utils.tales.ContextExprMixin.transform" title="Permalink to this definition">¶</a></dt>
       
  1477 <dd></dd></dl>
       
  1478 
       
  1479 </dd></dl>
       
  1480 
       
  1481 <dl class="class">
       
  1482 <dt id="pyams_utils.tales.ExtensionExpr">
       
  1483 <em class="property">class </em><code class="descclassname">pyams_utils.tales.</code><code class="descname">ExtensionExpr</code><span class="sig-paren">(</span><em>expression</em>, <em>braces_required=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.tales.ExtensionExpr" title="Permalink to this definition">¶</a></dt>
       
  1484 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.tales.ContextExprMixin" title="pyams_utils.tales.ContextExprMixin"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.tales.ContextExprMixin</span></code></a>, <code class="xref py py-class docutils literal"><span class="pre">chameleon.tales.StringExpr</span></code></p>
       
  1485 <p>extension: TALES expression</p>
       
  1486 <p>This expression can be used a call a custom named adapter providing ITALESExtension interface.</p>
       
  1487 <dl class="attribute">
       
  1488 <dt id="pyams_utils.tales.ExtensionExpr.transform">
       
  1489 <code class="descname">transform</code><em class="property"> = &lt;Symbol value=&lt;function render_extension&gt; at 7f3cb9015518&gt;</em><a class="headerlink" href="#pyams_utils.tales.ExtensionExpr.transform" title="Permalink to this definition">¶</a></dt>
       
  1490 <dd></dd></dl>
       
  1491 
       
  1492 </dd></dl>
       
  1493 
       
  1494 <dl class="function">
       
  1495 <dt id="pyams_utils.tales.render_extension">
       
  1496 <code class="descclassname">pyams_utils.tales.</code><code class="descname">render_extension</code><span class="sig-paren">(</span><em>econtext</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.tales.render_extension" title="Permalink to this definition">¶</a></dt>
       
  1497 <dd><p>TALES extension renderer</p>
       
  1498 <p>See <a class="reference internal" href="tales.html#tales"><span class="std std-ref">Custom TALES extensions</span></a> for complete description.</p>
       
  1499 </dd></dl>
       
  1500 
       
  1501 </div>
       
  1502 <div class="section" id="module-pyams_utils.text">
       
  1503 <span id="pyams-utils-text-module"></span><h2>pyams_utils.text module<a class="headerlink" href="#module-pyams_utils.text" title="Permalink to this headline">¶</a></h2>
       
  1504 <dl class="class">
       
  1505 <dt id="pyams_utils.text.BaseHTMLRenderer">
       
  1506 <em class="property">class </em><code class="descclassname">pyams_utils.text.</code><code class="descname">BaseHTMLRenderer</code><span class="sig-paren">(</span><em>context</em>, <em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.BaseHTMLRenderer" title="Permalink to this definition">¶</a></dt>
       
  1507 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
  1508 <p>Raw text HTML renderer</p>
       
  1509 <p>This renderer renders input text &#8216;as is&#8217;, mainly for use in a &lt;pre&gt; tag.</p>
       
  1510 <dl class="method">
       
  1511 <dt id="pyams_utils.text.BaseHTMLRenderer.render">
       
  1512 <code class="descname">render</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.BaseHTMLRenderer.render" title="Permalink to this definition">¶</a></dt>
       
  1513 <dd></dd></dl>
       
  1514 
       
  1515 </dd></dl>
       
  1516 
       
  1517 <dl class="class">
       
  1518 <dt id="pyams_utils.text.HTMLTalesExtension">
       
  1519 <em class="property">class </em><code class="descclassname">pyams_utils.text.</code><code class="descname">HTMLTalesExtension</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.HTMLTalesExtension" title="Permalink to this definition">¶</a></dt>
       
  1520 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="pyams_utils.adapter.ContextRequestViewAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextRequestViewAdapter</span></code></a></p>
       
  1521 <p><em>extension:html</em> TALES expression</p>
       
  1522 <p>If first <em>context</em> argument of the renderer is an object for which an <code class="xref py py-class docutils literal"><span class="pre">IHTMLRenderer</span></code>
       
  1523 can be found, this adapter is used to render the context to HTML; if <em>context</em> is a string,
       
  1524 it is converted to HTML using the renderer defined as second parameter; otherwise, context is just
       
  1525 converted to string using the <code class="xref py py-func docutils literal"><span class="pre">str()</span></code> function.</p>
       
  1526 <dl class="method">
       
  1527 <dt id="pyams_utils.text.HTMLTalesExtension.render">
       
  1528 <code class="descname">render</code><span class="sig-paren">(</span><em>context=None</em>, <em>renderer='text'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.HTMLTalesExtension.render" title="Permalink to this definition">¶</a></dt>
       
  1529 <dd></dd></dl>
       
  1530 
       
  1531 </dd></dl>
       
  1532 
       
  1533 <dl class="class">
       
  1534 <dt id="pyams_utils.text.ReStructuredTextRenderer">
       
  1535 <em class="property">class </em><code class="descclassname">pyams_utils.text.</code><code class="descname">ReStructuredTextRenderer</code><span class="sig-paren">(</span><em>context</em>, <em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.ReStructuredTextRenderer" title="Permalink to this definition">¶</a></dt>
       
  1536 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.text.BaseHTMLRenderer" title="pyams_utils.text.BaseHTMLRenderer"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.text.BaseHTMLRenderer</span></code></a></p>
       
  1537 <p>reStructuredText HTML renderer</p>
       
  1538 <p>This renderer is using <em>docutils</em> to render HTML output.</p>
       
  1539 <dl class="method">
       
  1540 <dt id="pyams_utils.text.ReStructuredTextRenderer.render">
       
  1541 <code class="descname">render</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.ReStructuredTextRenderer.render" title="Permalink to this definition">¶</a></dt>
       
  1542 <dd><p>Render reStructuredText to HTML</p>
       
  1543 </dd></dl>
       
  1544 
       
  1545 </dd></dl>
       
  1546 
       
  1547 <dl class="class">
       
  1548 <dt id="pyams_utils.text.RenderersVocabulary">
       
  1549 <em class="property">class </em><code class="descclassname">pyams_utils.text.</code><code class="descname">RenderersVocabulary</code><a class="headerlink" href="#pyams_utils.text.RenderersVocabulary" title="Permalink to this definition">¶</a></dt>
       
  1550 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema.vocabulary.SimpleVocabulary</span></code></p>
       
  1551 <p>Text renderers vocabulary</p>
       
  1552 </dd></dl>
       
  1553 
       
  1554 <dl class="class">
       
  1555 <dt id="pyams_utils.text.TextRenderer">
       
  1556 <em class="property">class </em><code class="descclassname">pyams_utils.text.</code><code class="descname">TextRenderer</code><span class="sig-paren">(</span><em>context</em>, <em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.TextRenderer" title="Permalink to this definition">¶</a></dt>
       
  1557 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.text.BaseHTMLRenderer" title="pyams_utils.text.BaseHTMLRenderer"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.text.BaseHTMLRenderer</span></code></a></p>
       
  1558 <p>Basic text HTML renderer</p>
       
  1559 <p>This renderer only replace newlines with HTML breaks.</p>
       
  1560 <dl class="method">
       
  1561 <dt id="pyams_utils.text.TextRenderer.render">
       
  1562 <code class="descname">render</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.TextRenderer.render" title="Permalink to this definition">¶</a></dt>
       
  1563 <dd></dd></dl>
       
  1564 
       
  1565 </dd></dl>
       
  1566 
       
  1567 <dl class="function">
       
  1568 <dt id="pyams_utils.text.get_text_start">
       
  1569 <code class="descclassname">pyams_utils.text.</code><code class="descname">get_text_start</code><span class="sig-paren">(</span><em>text</em>, <em>length</em>, <em>max=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.get_text_start" title="Permalink to this definition">¶</a></dt>
       
  1570 <dd><p>Get first words of given text with maximum given length</p>
       
  1571 <p>If <em>max</em> is specified, text is shortened only if remaining text is longer this value</p>
       
  1572 <table class="docutils field-list" frame="void" rules="none">
       
  1573 <col class="field-name" />
       
  1574 <col class="field-body" />
       
  1575 <tbody valign="top">
       
  1576 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1577 <li><strong>text</strong> (<em>str</em>) &#8211; initial text</li>
       
  1578 <li><strong>length</strong> (<em>integer</em>) &#8211; maximum length of resulting text</li>
       
  1579 <li><strong>max</strong> (<em>integer</em>) &#8211; if &gt; 0, <em>text</em> is shortened only if remaining text is longer than max</li>
       
  1580 </ul>
       
  1581 </td>
       
  1582 </tr>
       
  1583 </tbody>
       
  1584 </table>
       
  1585 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.text</span> <span class="k">import</span> <span class="n">get_text_start</span>
       
  1586 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_text_start</span><span class="p">(</span><span class="s">&#39;This is a long string&#39;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
       
  1587 <span class="go">&#39;This is a&amp;#133;&#39;</span>
       
  1588 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_text_start</span><span class="p">(</span><span class="s">&#39;This is a long string&#39;</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
       
  1589 <span class="go">&#39;This is a long&amp;#133;&#39;</span>
       
  1590 <span class="gp">&gt;&gt;&gt; </span><span class="n">get_text_start</span><span class="p">(</span><span class="s">&#39;This is a long string&#39;</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
       
  1591 <span class="go">&#39;This is a long string&#39;</span>
       
  1592 </pre></div>
       
  1593 </div>
       
  1594 </dd></dl>
       
  1595 
       
  1596 <dl class="function">
       
  1597 <dt id="pyams_utils.text.text_to_html">
       
  1598 <code class="descclassname">pyams_utils.text.</code><code class="descname">text_to_html</code><span class="sig-paren">(</span><em>text</em>, <em>renderer='text'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.text.text_to_html" title="Permalink to this definition">¶</a></dt>
       
  1599 <dd><p>Convert text to HTML using the given renderer</p>
       
  1600 <p>Renderer name can be any registered HTML renderer adapter</p>
       
  1601 </dd></dl>
       
  1602 
       
  1603 </div>
       
  1604 <div class="section" id="module-pyams_utils.traversing">
       
  1605 <span id="pyams-utils-traversing-module"></span><h2>pyams_utils.traversing module<a class="headerlink" href="#module-pyams_utils.traversing" title="Permalink to this headline">¶</a></h2>
       
  1606 <dl class="class">
       
  1607 <dt id="pyams_utils.traversing.NamespaceTraverser">
       
  1608 <em class="property">class </em><code class="descclassname">pyams_utils.traversing.</code><code class="descname">NamespaceTraverser</code><span class="sig-paren">(</span><em>root</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.traversing.NamespaceTraverser" title="Permalink to this definition">¶</a></dt>
       
  1609 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">pyramid.traversal.ResourceTreeTraverser</span></code></p>
       
  1610 <p>Custom traverser handling views and namespaces</p>
       
  1611 <p>This is an upgraded version of native Pyramid traverser.
       
  1612 It adds:
       
  1613 - a new BeforeTraverseEvent before traversing each object in the path
       
  1614 - support for namespaces with &#8220;++&#8221; notation</p>
       
  1615 <dl class="attribute">
       
  1616 <dt id="pyams_utils.traversing.NamespaceTraverser.NAMESPACE_SELECTOR">
       
  1617 <code class="descname">NAMESPACE_SELECTOR</code><em class="property"> = '++'</em><a class="headerlink" href="#pyams_utils.traversing.NamespaceTraverser.NAMESPACE_SELECTOR" title="Permalink to this definition">¶</a></dt>
       
  1618 <dd></dd></dl>
       
  1619 
       
  1620 </dd></dl>
       
  1621 
       
  1622 <dl class="class">
       
  1623 <dt id="pyams_utils.traversing.PathElementsAdapter">
       
  1624 <em class="property">class </em><code class="descclassname">pyams_utils.traversing.</code><code class="descname">PathElementsAdapter</code><span class="sig-paren">(</span><em>context</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.traversing.PathElementsAdapter" title="Permalink to this definition">¶</a></dt>
       
  1625 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextAdapter" title="pyams_utils.adapter.ContextAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextAdapter</span></code></a></p>
       
  1626 <p>Contained object path elements adapter</p>
       
  1627 <p>This interface is intended to be used inside a keyword index to
       
  1628 be able to search object based on a given parent</p>
       
  1629 <dl class="attribute">
       
  1630 <dt id="pyams_utils.traversing.PathElementsAdapter.parents">
       
  1631 <code class="descname">parents</code><a class="headerlink" href="#pyams_utils.traversing.PathElementsAdapter.parents" title="Permalink to this definition">¶</a></dt>
       
  1632 <dd></dd></dl>
       
  1633 
       
  1634 </dd></dl>
       
  1635 
       
  1636 <dl class="function">
       
  1637 <dt id="pyams_utils.traversing.get_parent">
       
  1638 <code class="descclassname">pyams_utils.traversing.</code><code class="descname">get_parent</code><span class="sig-paren">(</span><em>context</em>, <em>interface=&lt;InterfaceClass zope.interface.Interface&gt;</em>, <em>allow_context=True</em>, <em>condition=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.traversing.get_parent" title="Permalink to this definition">¶</a></dt>
       
  1639 <dd><p>Get first parent of the context that implements given interface</p>
       
  1640 <table class="docutils field-list" frame="void" rules="none">
       
  1641 <col class="field-name" />
       
  1642 <col class="field-body" />
       
  1643 <tbody valign="top">
       
  1644 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1645 <li><strong>context</strong> (<em>object</em>) &#8211; base element</li>
       
  1646 <li><strong>interface</strong> (<em>Interface</em>) &#8211; the interface that parend should implement</li>
       
  1647 <li><strong>allow_context</strong> (<em>boolean</em>) &#8211; if &#8216;True&#8217; (the default), traversing is done starting with context; otherwise,
       
  1648 traversing is done starting from context&#8217;s parent</li>
       
  1649 <li><strong>condition</strong> (<em>callable</em>) &#8211; an optional function that should return a &#8216;True&#8217; result when called with parent
       
  1650 as first argument</li>
       
  1651 </ul>
       
  1652 </td>
       
  1653 </tr>
       
  1654 </tbody>
       
  1655 </table>
       
  1656 </dd></dl>
       
  1657 
       
  1658 </div>
       
  1659 <div class="section" id="module-pyams_utils.unicode">
       
  1660 <span id="pyams-utils-unicode-module"></span><h2>pyams_utils.unicode module<a class="headerlink" href="#module-pyams_utils.unicode" title="Permalink to this headline">¶</a></h2>
       
  1661 <dl class="function">
       
  1662 <dt id="pyams_utils.unicode.decode">
       
  1663 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">decode</code><span class="sig-paren">(</span><em>value</em>, <em>encoding='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.decode" title="Permalink to this definition">¶</a></dt>
       
  1664 <dd><p>Decode given bytes value to unicode with given encoding</p>
       
  1665 <table class="docutils field-list" frame="void" rules="none">
       
  1666 <col class="field-name" />
       
  1667 <col class="field-body" />
       
  1668 <tbody valign="top">
       
  1669 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1670 <li><strong>value</strong> (<em>bytes</em>) &#8211; the value to decode</li>
       
  1671 <li><strong>encoding</strong> (<em>str</em>) &#8211; selected encoding</li>
       
  1672 </ul>
       
  1673 </td>
       
  1674 </tr>
       
  1675 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str; value decoded to unicode string if input is a bytes, original value otherwise</p>
       
  1676 </td>
       
  1677 </tr>
       
  1678 </tbody>
       
  1679 </table>
       
  1680 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">decode</span>
       
  1681 <span class="gp">&gt;&gt;&gt; </span><span class="n">decode</span><span class="p">(</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xc3\xae</span><span class="s">ne accentu</span><span class="se">\xc3\xa9</span><span class="s">e&#39;</span><span class="p">)</span>
       
  1682 <span class="go">&#39;Chaîne accentuée&#39;</span>
       
  1683 <span class="gp">&gt;&gt;&gt; </span><span class="n">decode</span><span class="p">(</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xee</span><span class="s">ne accentu</span><span class="se">\xe9</span><span class="s">e&#39;</span><span class="p">,</span> <span class="s">&#39;latin1&#39;</span><span class="p">)</span>
       
  1684 <span class="go">&#39;Chaîne accentuée&#39;</span>
       
  1685 </pre></div>
       
  1686 </div>
       
  1687 </dd></dl>
       
  1688 
       
  1689 <dl class="function">
       
  1690 <dt id="pyams_utils.unicode.encode">
       
  1691 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">encode</code><span class="sig-paren">(</span><em>value</em>, <em>encoding='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.encode" title="Permalink to this definition">¶</a></dt>
       
  1692 <dd><p>Encode given Unicode value to bytes with given encoding</p>
       
  1693 <table class="docutils field-list" frame="void" rules="none">
       
  1694 <col class="field-name" />
       
  1695 <col class="field-body" />
       
  1696 <tbody valign="top">
       
  1697 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1698 <li><strong>value</strong> (<em>str</em>) &#8211; the value to encode</li>
       
  1699 <li><strong>encoding</strong> (<em>str</em>) &#8211; selected encoding</li>
       
  1700 </ul>
       
  1701 </td>
       
  1702 </tr>
       
  1703 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">bytes; value encoded to bytes if input is a string, original value otherwise</p>
       
  1704 </td>
       
  1705 </tr>
       
  1706 </tbody>
       
  1707 </table>
       
  1708 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">encode</span>
       
  1709 <span class="gp">&gt;&gt;&gt; </span><span class="n">encode</span><span class="p">(</span><span class="s">&#39;Chaîne accentuée&#39;</span><span class="p">)</span>
       
  1710 <span class="go">b&#39;Cha\xc3\xaene accentu\xc3\xa9e&#39;</span>
       
  1711 <span class="gp">&gt;&gt;&gt; </span><span class="n">encode</span><span class="p">(</span><span class="s">&#39;Chaîne accentuée&#39;</span><span class="p">,</span> <span class="s">&#39;latin1&#39;</span><span class="p">)</span>
       
  1712 <span class="go">b&#39;Cha\xeene accentu\xe9e&#39;</span>
       
  1713 </pre></div>
       
  1714 </div>
       
  1715 </dd></dl>
       
  1716 
       
  1717 <dl class="function">
       
  1718 <dt id="pyams_utils.unicode.nvl">
       
  1719 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">nvl</code><span class="sig-paren">(</span><em>value</em>, <em>default=''</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.nvl" title="Permalink to this definition">¶</a></dt>
       
  1720 <dd><p>Get specified value, or an empty string if value is empty</p>
       
  1721 <table class="docutils field-list" frame="void" rules="none">
       
  1722 <col class="field-name" />
       
  1723 <col class="field-body" />
       
  1724 <tbody valign="top">
       
  1725 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1726 <li><strong>value</strong> (<em>object</em>) &#8211; value to be checked</li>
       
  1727 <li><strong>default</strong> (<em>object</em>) &#8211; default value to be returned if value is <em>false</em></li>
       
  1728 </ul>
       
  1729 </td>
       
  1730 </tr>
       
  1731 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">input value, or <em>default</em> if value is <em>false</em></p>
       
  1732 </td>
       
  1733 </tr>
       
  1734 </tbody>
       
  1735 </table>
       
  1736 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">nvl</span>
       
  1737 <span class="gp">&gt;&gt;&gt; </span><span class="n">nvl</span><span class="p">(</span><span class="k">None</span><span class="p">)</span>
       
  1738 <span class="go">&#39;&#39;</span>
       
  1739 <span class="gp">&gt;&gt;&gt; </span><span class="n">nvl</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
       
  1740 <span class="go">&#39;foo&#39;</span>
       
  1741 <span class="gp">&gt;&gt;&gt; </span><span class="n">nvl</span><span class="p">(</span><span class="k">False</span><span class="p">,</span> <span class="s">&#39;bar&#39;</span><span class="p">)</span>
       
  1742 <span class="go">&#39;bar&#39;</span>
       
  1743 </pre></div>
       
  1744 </div>
       
  1745 </dd></dl>
       
  1746 
       
  1747 <dl class="function">
       
  1748 <dt id="pyams_utils.unicode.translate_string">
       
  1749 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">translate_string</code><span class="sig-paren">(</span><em>s</em>, <em>escape_slashes=False</em>, <em>force_lower=True</em>, <em>spaces=' '</em>, <em>remove_punctuation=True</em>, <em>keep_chars='_-.'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.translate_string" title="Permalink to this definition">¶</a></dt>
       
  1750 <dd><p>Remove extended characters and diacritics from string and replace them with &#8216;basic&#8217; ones</p>
       
  1751 <table class="docutils field-list" frame="void" rules="none">
       
  1752 <col class="field-name" />
       
  1753 <col class="field-body" />
       
  1754 <tbody valign="top">
       
  1755 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1756 <li><strong>s</strong> (<em>str</em>) &#8211; text to be cleaned.</li>
       
  1757 <li><strong>escape_slashes</strong> (<em>boolean</em>) &#8211; if True, slashes are also converted</li>
       
  1758 <li><strong>force_lower</strong> (<em>boolean</em>) &#8211; if True, result is automatically converted to lower case</li>
       
  1759 <li><strong>spaces</strong> (<em>str</em>) &#8211; character used to replace spaces</li>
       
  1760 <li><strong>remove_punctuation</strong> (<em>boolean</em>) &#8211; if True, all punctuation characters are removed</li>
       
  1761 <li><strong>keep_chars</strong> (<em>str</em>) &#8211; characters which may be kept in the input string</li>
       
  1762 </ul>
       
  1763 </td>
       
  1764 </tr>
       
  1765 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">text without diacritics or special characters</p>
       
  1766 </td>
       
  1767 </tr>
       
  1768 </tbody>
       
  1769 </table>
       
  1770 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">translate_string</span>
       
  1771 <span class="gp">&gt;&gt;&gt; </span><span class="nb">input</span> <span class="o">=</span> <span class="s">&#39;Ceci est un test en Français !!!&#39;</span>
       
  1772 <span class="gp">&gt;&gt;&gt; </span><span class="n">translate_string</span><span class="p">(</span><span class="nb">input</span><span class="p">)</span>
       
  1773 <span class="go">&#39;ceci est un test en francais&#39;</span>
       
  1774 <span class="gp">&gt;&gt;&gt; </span><span class="n">translate_string</span><span class="p">(</span><span class="nb">input</span><span class="p">,</span> <span class="n">force_lower</span><span class="o">=</span><span class="k">False</span><span class="p">)</span>
       
  1775 <span class="go">&#39;Ceci est un test en Francais&#39;</span>
       
  1776 <span class="gp">&gt;&gt;&gt; </span><span class="n">translate_string</span><span class="p">(</span><span class="nb">input</span><span class="p">,</span> <span class="n">spaces</span><span class="o">=</span><span class="s">&#39;-&#39;</span><span class="p">)</span>
       
  1777 <span class="go">&#39;ceci-est-un-test-en-francais&#39;</span>
       
  1778 <span class="gp">&gt;&gt;&gt; </span><span class="n">translate_string</span><span class="p">(</span><span class="nb">input</span><span class="p">,</span> <span class="n">remove_punctuation</span><span class="o">=</span><span class="k">False</span><span class="p">)</span>
       
  1779 <span class="go">&#39;ceci est un test en francais !!!&#39;</span>
       
  1780 <span class="gp">&gt;&gt;&gt; </span><span class="n">translate_string</span><span class="p">(</span><span class="nb">input</span><span class="p">,</span> <span class="n">keep_chars</span><span class="o">=</span><span class="s">&#39;!&#39;</span><span class="p">)</span>
       
  1781 <span class="go">&#39;ceci est un test en francais !!!&#39;</span>
       
  1782 </pre></div>
       
  1783 </div>
       
  1784 </dd></dl>
       
  1785 
       
  1786 <dl class="function">
       
  1787 <dt id="pyams_utils.unicode.unidict">
       
  1788 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">unidict</code><span class="sig-paren">(</span><em>value</em>, <em>encoding='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.unidict" title="Permalink to this definition">¶</a></dt>
       
  1789 <dd><p>Get specified dict with values converted to unicode</p>
       
  1790 <table class="docutils field-list" frame="void" rules="none">
       
  1791 <col class="field-name" />
       
  1792 <col class="field-body" />
       
  1793 <tbody valign="top">
       
  1794 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<em>dict</em>) &#8211; input mapping of strings which may be converted to unicode</td>
       
  1795 </tr>
       
  1796 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">dict; a new mapping with each value converted to unicode</td>
       
  1797 </tr>
       
  1798 </tbody>
       
  1799 </table>
       
  1800 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">unidict</span>
       
  1801 <span class="gp">&gt;&gt;&gt; </span><span class="n">unidict</span><span class="p">({</span><span class="s">&#39;input&#39;</span><span class="p">:</span> <span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xc3\xae</span><span class="s">ne accentu</span><span class="se">\xc3\xa9</span><span class="s">e&#39;</span><span class="p">})</span>
       
  1802 <span class="go">{&#39;input&#39;: &#39;Chaîne accentuée&#39;}</span>
       
  1803 <span class="gp">&gt;&gt;&gt; </span><span class="n">unidict</span><span class="p">({</span><span class="s">&#39;input&#39;</span><span class="p">:</span> <span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xee</span><span class="s">ne accentu</span><span class="se">\xe9</span><span class="s">e&#39;</span><span class="p">},</span> <span class="s">&#39;latin1&#39;</span><span class="p">)</span>
       
  1804 <span class="go">{&#39;input&#39;: &#39;Chaîne accentuée&#39;}</span>
       
  1805 </pre></div>
       
  1806 </div>
       
  1807 </dd></dl>
       
  1808 
       
  1809 <dl class="function">
       
  1810 <dt id="pyams_utils.unicode.unilist">
       
  1811 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">unilist</code><span class="sig-paren">(</span><em>value</em>, <em>encoding='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.unilist" title="Permalink to this definition">¶</a></dt>
       
  1812 <dd><p>Get specified list with values converted to unicode</p>
       
  1813 <table class="docutils field-list" frame="void" rules="none">
       
  1814 <col class="field-name" />
       
  1815 <col class="field-body" />
       
  1816 <tbody valign="top">
       
  1817 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<a class="reference internal" href="#module-pyams_utils.list" title="pyams_utils.list"><em>list</em></a>) &#8211; input list of strings which may be converted to unicode</td>
       
  1818 </tr>
       
  1819 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list; a new list with each value converted to unicode</td>
       
  1820 </tr>
       
  1821 </tbody>
       
  1822 </table>
       
  1823 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">unilist</span>
       
  1824 <span class="gp">&gt;&gt;&gt; </span><span class="n">unilist</span><span class="p">([</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xc3\xae</span><span class="s">ne accentu</span><span class="se">\xc3\xa9</span><span class="s">e&#39;</span><span class="p">])</span>
       
  1825 <span class="go">[&#39;Chaîne accentuée&#39;]</span>
       
  1826 <span class="gp">&gt;&gt;&gt; </span><span class="n">unilist</span><span class="p">([</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xee</span><span class="s">ne accentu</span><span class="se">\xe9</span><span class="s">e&#39;</span><span class="p">],</span> <span class="s">&#39;latin1&#39;</span><span class="p">)</span>
       
  1827 <span class="go">[&#39;Chaîne accentuée&#39;]</span>
       
  1828 </pre></div>
       
  1829 </div>
       
  1830 </dd></dl>
       
  1831 
       
  1832 <dl class="function">
       
  1833 <dt id="pyams_utils.unicode.uninvl">
       
  1834 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">uninvl</code><span class="sig-paren">(</span><em>value</em>, <em>default=''</em>, <em>encoding='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.uninvl" title="Permalink to this definition">¶</a></dt>
       
  1835 <dd><p>Get specified value converted to unicode, or an empty unicode string if value is empty</p>
       
  1836 <table class="docutils field-list" frame="void" rules="none">
       
  1837 <col class="field-name" />
       
  1838 <col class="field-body" />
       
  1839 <tbody valign="top">
       
  1840 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  1841 <li><strong>value</strong> (<em>str/bytes</em>) &#8211; the input to be checked</li>
       
  1842 <li><strong>default</strong> &#8211; str; default value</li>
       
  1843 <li><strong>encoding</strong> &#8211; str; encoding name to use for conversion</li>
       
  1844 </ul>
       
  1845 </td>
       
  1846 </tr>
       
  1847 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str; value, or <em>default</em> if value is empty, converted to unicode</p>
       
  1848 </td>
       
  1849 </tr>
       
  1850 </tbody>
       
  1851 </table>
       
  1852 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">uninvl</span>
       
  1853 <span class="gp">&gt;&gt;&gt; </span><span class="n">uninvl</span><span class="p">(</span><span class="s">&#39;String value&#39;</span><span class="p">)</span>
       
  1854 <span class="go">&#39;String value&#39;</span>
       
  1855 <span class="gp">&gt;&gt;&gt; </span><span class="n">uninvl</span><span class="p">(</span><span class="n">b</span><span class="s">&#39;String value&#39;</span><span class="p">)</span>
       
  1856 <span class="go">&#39;String value&#39;</span>
       
  1857 <span class="gp">&gt;&gt;&gt; </span><span class="n">uninvl</span><span class="p">(</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xc3\xae</span><span class="s">ne accentu</span><span class="se">\xc3\xa9</span><span class="s">e&#39;</span><span class="p">)</span>
       
  1858 <span class="go">&#39;Chaîne accentuée&#39;</span>
       
  1859 <span class="gp">&gt;&gt;&gt; </span><span class="n">uninvl</span><span class="p">(</span><span class="n">b</span><span class="s">&#39;Cha</span><span class="se">\xee</span><span class="s">ne accentu</span><span class="se">\xe9</span><span class="s">e&#39;</span><span class="p">,</span> <span class="s">&#39;latin1&#39;</span><span class="p">)</span>
       
  1860 <span class="go">&#39;Chaîne accentuée&#39;</span>
       
  1861 </pre></div>
       
  1862 </div>
       
  1863 </dd></dl>
       
  1864 
       
  1865 <dl class="function">
       
  1866 <dt id="pyams_utils.unicode.utf8">
       
  1867 <code class="descclassname">pyams_utils.unicode.</code><code class="descname">utf8</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.unicode.utf8" title="Permalink to this definition">¶</a></dt>
       
  1868 <dd><p>Encode given unicode value to UTF-8 encoded bytes</p>
       
  1869 <table class="docutils field-list" frame="void" rules="none">
       
  1870 <col class="field-name" />
       
  1871 <col class="field-body" />
       
  1872 <tbody valign="top">
       
  1873 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> (<em>str</em>) &#8211; the value to encode to utf-8</td>
       
  1874 </tr>
       
  1875 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">bytes; value encoded to bytes if input is a string, original value otherwise</td>
       
  1876 </tr>
       
  1877 </tbody>
       
  1878 </table>
       
  1879 <div class="highlight-default"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyams_utils.unicode</span> <span class="k">import</span> <span class="n">utf8</span>
       
  1880 <span class="gp">&gt;&gt;&gt; </span><span class="n">utf8</span><span class="p">(</span><span class="s">&#39;Chaîne accentuée&#39;</span><span class="p">)</span>
       
  1881 <span class="go">b&#39;Cha\xc3\xaene accentu\xc3\xa9e&#39;</span>
       
  1882 </pre></div>
       
  1883 </div>
       
  1884 </dd></dl>
       
  1885 
       
  1886 </div>
       
  1887 <div class="section" id="module-pyams_utils.url">
       
  1888 <span id="pyams-utils-url-module"></span><h2>pyams_utils.url module<a class="headerlink" href="#module-pyams_utils.url" title="Permalink to this headline">¶</a></h2>
       
  1889 <dl class="class">
       
  1890 <dt id="pyams_utils.url.AbsoluteUrlTalesExtension">
       
  1891 <em class="property">class </em><code class="descclassname">pyams_utils.url.</code><code class="descname">AbsoluteUrlTalesExtension</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.url.AbsoluteUrlTalesExtension" title="Permalink to this definition">¶</a></dt>
       
  1892 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.adapter.ContextRequestViewAdapter" title="pyams_utils.adapter.ContextRequestViewAdapter"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.adapter.ContextRequestViewAdapter</span></code></a></p>
       
  1893 <p>extension:absolute_url(context, view_name) TALES extension</p>
       
  1894 <p>A PyAMS TALES extension used to get access to an object URL from a page template.</p>
       
  1895 <dl class="method">
       
  1896 <dt id="pyams_utils.url.AbsoluteUrlTalesExtension.render">
       
  1897 <code class="descname">render</code><span class="sig-paren">(</span><em>context=None</em>, <em>view_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.url.AbsoluteUrlTalesExtension.render" title="Permalink to this definition">¶</a></dt>
       
  1898 <dd></dd></dl>
       
  1899 
       
  1900 </dd></dl>
       
  1901 
       
  1902 <dl class="function">
       
  1903 <dt id="pyams_utils.url.absolute_url">
       
  1904 <code class="descclassname">pyams_utils.url.</code><code class="descname">absolute_url</code><span class="sig-paren">(</span><em>context</em>, <em>request</em>, <em>view_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.url.absolute_url" title="Permalink to this definition">¶</a></dt>
       
  1905 <dd><p>Get resource absolute_url</p>
       
  1906 <table class="docutils field-list" frame="void" rules="none">
       
  1907 <col class="field-name" />
       
  1908 <col class="field-body" />
       
  1909 <tbody valign="top">
       
  1910 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
       
  1911 <li><strong>context</strong> (<em>object</em>) &#8211; the persistent object for which absolute URL is required</li>
       
  1912 <li><strong>request</strong> &#8211; the request on which URL is based</li>
       
  1913 <li><strong>view_name</strong> (<em>str</em>) &#8211; an optional view name to add to URL</li>
       
  1914 </ul>
       
  1915 </td>
       
  1916 </tr>
       
  1917 </tbody>
       
  1918 </table>
       
  1919 <p>This absolute URL function is based on default Pyramid&#8217;s <code class="xref py py-func docutils literal"><span class="pre">resource_url()</span></code> function, but
       
  1920 add checks to remove some double slashes, and add control on view name when it begins with a &#8216;#&#8217;
       
  1921 character which is used by MyAMS.js framework.</p>
       
  1922 </dd></dl>
       
  1923 
       
  1924 </div>
       
  1925 <div class="section" id="module-pyams_utils.vocabulary">
       
  1926 <span id="pyams-utils-vocabulary-module"></span><h2>pyams_utils.vocabulary module<a class="headerlink" href="#module-pyams_utils.vocabulary" title="Permalink to this headline">¶</a></h2>
       
  1927 <dl class="class">
       
  1928 <dt id="pyams_utils.vocabulary.vocabulary_config">
       
  1929 <em class="property">class </em><code class="descclassname">pyams_utils.vocabulary.</code><code class="descname">vocabulary_config</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.vocabulary.vocabulary_config" title="Permalink to this definition">¶</a></dt>
       
  1930 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
  1931 <p>Class decorator to define a vocabulary</p>
       
  1932 <table class="docutils field-list" frame="void" rules="none">
       
  1933 <col class="field-name" />
       
  1934 <col class="field-body" />
       
  1935 <tbody valign="top">
       
  1936 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) &#8211; name of the registered vocabulary</td>
       
  1937 </tr>
       
  1938 </tbody>
       
  1939 </table>
       
  1940 <p>This is, for example, how a vocabulary of registered ZEO connections utilities is created:</p>
       
  1941 <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_utils.interfaces.zeo</span> <span class="kn">import</span> <span class="n">IZEOConnection</span>
       
  1942 
       
  1943 <span class="kn">from</span> <span class="nn">pyams_utils.registry</span> <span class="kn">import</span> <span class="n">get_utilities_for</span>
       
  1944 <span class="kn">from</span> <span class="nn">pyams_utils.vocabulary</span> <span class="kn">import</span> <span class="n">vocabulary_config</span>
       
  1945 <span class="kn">from</span> <span class="nn">zope.schema.vocabulary</span> <span class="kn">import</span> <span class="n">SimpleTerm</span><span class="p">,</span> <span class="n">SimpleVocabulary</span>
       
  1946 
       
  1947 <span class="nd">@vocabulary_config</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;PyAMS ZEO connections&#39;</span><span class="p">)</span>
       
  1948 <span class="k">class</span> <span class="nc">ZEOConnectionVocabulary</span><span class="p">(</span><span class="n">SimpleVocabulary</span><span class="p">):</span>
       
  1949     <span class="sd">&#39;&#39;&#39;ZEO connections vocabulary&#39;&#39;&#39;</span>
       
  1950 
       
  1951     <span class="k">def</span> <span class="nf">__init__</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>
       
  1952         <span class="n">terms</span> <span class="o">=</span> <span class="p">[</span><span class="n">SimpleTerm</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="n">util</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">util</span> <span class="ow">in</span> <span class="n">get_utilities_for</span><span class="p">(</span><span class="n">IZEOConnection</span><span class="p">)]</span>
       
  1953         <span class="nb">super</span><span class="p">(</span><span class="n">ZEOConnectionVocabulary</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="n">terms</span><span class="p">)</span>
       
  1954 </pre></div>
       
  1955 </div>
       
  1956 <p>You can then use such a vocabulary in any schema field:</p>
       
  1957 <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">zope.interface</span> <span class="kn">import</span> <span class="n">Interface</span>
       
  1958 <span class="kn">from</span> <span class="nn">zope.schema</span> <span class="kn">import</span> <span class="n">Choice</span>
       
  1959 
       
  1960 <span class="k">class</span> <span class="nc">MySchema</span><span class="p">(</span><span class="n">Interface</span><span class="p">):</span>
       
  1961     <span class="sd">&#39;&#39;&#39;Custom schema interface&#39;&#39;&#39;</span>
       
  1962 
       
  1963     <span class="n">zeo_connection_name</span> <span class="o">=</span> <span class="n">Choice</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s">&#39;ZEO connection name&#39;</span><span class="p">,</span>
       
  1964                                  <span class="n">description</span><span class="o">=</span><span class="s">&#39;Please select a registered ZEO connection&#39;</span><span class="p">,</span>
       
  1965                                  <span class="n">vocabulary</span><span class="o">=</span><span class="s">&#39;PyAMS ZEO connections&#39;</span><span class="p">,</span>
       
  1966                                  <span class="n">required</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
       
  1967 </pre></div>
       
  1968 </div>
       
  1969 </dd></dl>
       
  1970 
       
  1971 </div>
       
  1972 <div class="section" id="module-pyams_utils.wsgi">
       
  1973 <span id="pyams-utils-wsgi-module"></span><h2>pyams_utils.wsgi module<a class="headerlink" href="#module-pyams_utils.wsgi" title="Permalink to this headline">¶</a></h2>
       
  1974 <dl class="function">
       
  1975 <dt id="pyams_utils.wsgi.wsgi_environ_cache">
       
  1976 <code class="descclassname">pyams_utils.wsgi.</code><code class="descname">wsgi_environ_cache</code><span class="sig-paren">(</span><em>*names</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.wsgi.wsgi_environ_cache" title="Permalink to this definition">¶</a></dt>
       
  1977 <dd><p>Wrap a function/method to cache its result for call into request.environ</p>
       
  1978 <table class="docutils field-list" frame="void" rules="none">
       
  1979 <col class="field-name" />
       
  1980 <col class="field-body" />
       
  1981 <tbody valign="top">
       
  1982 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>names</strong> (<em>[string...]</em>) &#8211; keys to cache into environ; len(names) must
       
  1983 be equal to the result&#8217;s length or scalar</td>
       
  1984 </tr>
       
  1985 </tbody>
       
  1986 </table>
       
  1987 </dd></dl>
       
  1988 
       
  1989 </div>
       
  1990 <div class="section" id="module-pyams_utils.zodb">
       
  1991 <span id="pyams-utils-zodb-module"></span><h2>pyams_utils.zodb module<a class="headerlink" href="#module-pyams_utils.zodb" title="Permalink to this headline">¶</a></h2>
       
  1992 <dl class="class">
       
  1993 <dt id="pyams_utils.zodb.ZEOConnection">
       
  1994 <em class="property">class </em><code class="descclassname">pyams_utils.zodb.</code><code class="descname">ZEOConnection</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection" title="Permalink to this definition">¶</a></dt>
       
  1995 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
       
  1996 <p>ZEO connection object</p>
       
  1997 <p>This object can be used to store all settings to be able to open a ZEO connection.</p>
       
  1998 <p>Note that a ZEO connection object is a context manager, so you can use it like this:</p>
       
  1999 <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyams_utils.zodb</span> <span class="kn">import</span> <span class="n">ZEOConnection</span>
       
  2000 
       
  2001 <span class="k">def</span> <span class="nf">my_method</span><span class="p">(</span><span class="n">zeo_settings</span><span class="p">):</span>
       
  2002     <span class="n">zeo_connection</span> <span class="o">=</span> <span class="n">ZEOConnection</span><span class="p">()</span>
       
  2003     <span class="n">zeo_connection</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">zeo_settings</span><span class="p">)</span>
       
  2004     <span class="k">with</span> <span class="n">zeo_connection</span> <span class="k">as</span> <span class="n">root</span><span class="p">:</span>
       
  2005         <span class="c"># *root* is then the ZODB root object</span>
       
  2006         <span class="c"># do whatever you want with ZEO connection,</span>
       
  2007         <span class="c"># which is closed automatically</span>
       
  2008 </pre></div>
       
  2009 </div>
       
  2010 <dl class="attribute">
       
  2011 <dt id="pyams_utils.zodb.ZEOConnection.blob_dir">
       
  2012 <code class="descname">blob_dir</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.blob_dir" title="Permalink to this definition">¶</a></dt>
       
  2013 <dd><p>Directory path for blob data</p>
       
  2014 </dd></dl>
       
  2015 
       
  2016 <dl class="attribute">
       
  2017 <dt id="pyams_utils.zodb.ZEOConnection.connection">
       
  2018 <code class="descname">connection</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.connection" title="Permalink to this definition">¶</a></dt>
       
  2019 <dd></dd></dl>
       
  2020 
       
  2021 <dl class="method">
       
  2022 <dt id="pyams_utils.zodb.ZEOConnection.get_connection">
       
  2023 <code class="descname">get_connection</code><span class="sig-paren">(</span><em>wait=False</em>, <em>get_storage=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.get_connection" title="Permalink to this definition">¶</a></dt>
       
  2024 <dd><p>Create ZEO client connection from current settings</p>
       
  2025 <table class="docutils field-list" frame="void" rules="none">
       
  2026 <col class="field-name" />
       
  2027 <col class="field-body" />
       
  2028 <tbody valign="top">
       
  2029 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
       
  2030 <li><strong>wait</strong> (<em>boolean</em>) &#8211; should connection wait until storage is ready</li>
       
  2031 <li><strong>get_storage</strong> (<em>boolean</em>) &#8211; if <em>True</em>, the method should return a tuple containing
       
  2032 storage and DB objects; otherwise only DB object is returned</li>
       
  2033 </ul>
       
  2034 </td>
       
  2035 </tr>
       
  2036 <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple containing ZEO client storage and DB object (if <em>get_storage</em> argument is
       
  2037 set to <em>True</em>), or only DB object otherwise</p>
       
  2038 </td>
       
  2039 </tr>
       
  2040 </tbody>
       
  2041 </table>
       
  2042 </dd></dl>
       
  2043 
       
  2044 <dl class="method">
       
  2045 <dt id="pyams_utils.zodb.ZEOConnection.get_settings">
       
  2046 <code class="descname">get_settings</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.get_settings" title="Permalink to this definition">¶</a></dt>
       
  2047 <dd><p>Get mapping of all connection settings</p>
       
  2048 <p>These settings can be converted to JSON and sent to another process, for example
       
  2049 via a ØMQ connection.</p>
       
  2050 <table class="docutils field-list" frame="void" rules="none">
       
  2051 <col class="field-name" />
       
  2052 <col class="field-body" />
       
  2053 <tbody valign="top">
       
  2054 <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">dict</td>
       
  2055 </tr>
       
  2056 </tbody>
       
  2057 </table>
       
  2058 </dd></dl>
       
  2059 
       
  2060 <dl class="attribute">
       
  2061 <dt id="pyams_utils.zodb.ZEOConnection.name">
       
  2062 <code class="descname">name</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.name" title="Permalink to this definition">¶</a></dt>
       
  2063 <dd><p>Registration name of ZEO connection</p>
       
  2064 </dd></dl>
       
  2065 
       
  2066 <dl class="attribute">
       
  2067 <dt id="pyams_utils.zodb.ZEOConnection.password">
       
  2068 <code class="descname">password</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.password" title="Permalink to this definition">¶</a></dt>
       
  2069 <dd><p>User password on ZEO server</p>
       
  2070 </dd></dl>
       
  2071 
       
  2072 <dl class="attribute">
       
  2073 <dt id="pyams_utils.zodb.ZEOConnection.server_name">
       
  2074 <code class="descname">server_name</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.server_name" title="Permalink to this definition">¶</a></dt>
       
  2075 <dd><p>Hostname of ZEO server</p>
       
  2076 </dd></dl>
       
  2077 
       
  2078 <dl class="attribute">
       
  2079 <dt id="pyams_utils.zodb.ZEOConnection.server_port">
       
  2080 <code class="descname">server_port</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.server_port" title="Permalink to this definition">¶</a></dt>
       
  2081 <dd><p>Port number of ZEO server</p>
       
  2082 </dd></dl>
       
  2083 
       
  2084 <dl class="attribute">
       
  2085 <dt id="pyams_utils.zodb.ZEOConnection.server_realm">
       
  2086 <code class="descname">server_realm</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.server_realm" title="Permalink to this definition">¶</a></dt>
       
  2087 <dd><p>Realm name on ZEO server</p>
       
  2088 </dd></dl>
       
  2089 
       
  2090 <dl class="attribute">
       
  2091 <dt id="pyams_utils.zodb.ZEOConnection.shared_blob_dir">
       
  2092 <code class="descname">shared_blob_dir</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.shared_blob_dir" title="Permalink to this definition">¶</a></dt>
       
  2093 <dd><p>Flag whether the blob_dir is a server-shared filesystem that should be used instead of transferring blob data over zrpc.</p>
       
  2094 </dd></dl>
       
  2095 
       
  2096 <dl class="attribute">
       
  2097 <dt id="pyams_utils.zodb.ZEOConnection.storage">
       
  2098 <code class="descname">storage</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.storage" title="Permalink to this definition">¶</a></dt>
       
  2099 <dd><p>Storage name on ZEO server</p>
       
  2100 </dd></dl>
       
  2101 
       
  2102 <dl class="method">
       
  2103 <dt id="pyams_utils.zodb.ZEOConnection.update">
       
  2104 <code class="descname">update</code><span class="sig-paren">(</span><em>settings</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.update" title="Permalink to this definition">¶</a></dt>
       
  2105 <dd><p>Update connection properties with settings as <em>dict</em></p>
       
  2106 <table class="docutils field-list" frame="void" rules="none">
       
  2107 <col class="field-name" />
       
  2108 <col class="field-body" />
       
  2109 <tbody valign="top">
       
  2110 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>settings</strong> (<em>dict</em>) &#8211; typically extracted via the <a class="reference internal" href="#pyams_utils.zodb.ZEOConnection.get_settings" title="pyams_utils.zodb.ZEOConnection.get_settings"><code class="xref py py-meth docutils literal"><span class="pre">get_settings()</span></code></a> method from
       
  2111 another process</td>
       
  2112 </tr>
       
  2113 </tbody>
       
  2114 </table>
       
  2115 </dd></dl>
       
  2116 
       
  2117 <dl class="attribute">
       
  2118 <dt id="pyams_utils.zodb.ZEOConnection.username">
       
  2119 <code class="descname">username</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnection.username" title="Permalink to this definition">¶</a></dt>
       
  2120 <dd><p>User name on ZEO server</p>
       
  2121 </dd></dl>
       
  2122 
       
  2123 </dd></dl>
       
  2124 
       
  2125 <dl class="class">
       
  2126 <dt id="pyams_utils.zodb.ZEOConnectionUtility">
       
  2127 <em class="property">class </em><code class="descclassname">pyams_utils.zodb.</code><code class="descname">ZEOConnectionUtility</code><a class="headerlink" href="#pyams_utils.zodb.ZEOConnectionUtility" title="Permalink to this definition">¶</a></dt>
       
  2128 <dd><p>Bases: <a class="reference internal" href="#pyams_utils.zodb.ZEOConnection" title="pyams_utils.zodb.ZEOConnection"><code class="xref py py-class docutils literal"><span class="pre">pyams_utils.zodb.ZEOConnection</span></code></a>, <code class="xref py py-class docutils literal"><span class="pre">persistent.Persistent</span></code>, <code class="xref py py-class docutils literal"><span class="pre">zope.container.contained.Contained</span></code></p>
       
  2129 <p>Persistent ZEO connection utility</p>
       
  2130 </dd></dl>
       
  2131 
       
  2132 <dl class="class">
       
  2133 <dt id="pyams_utils.zodb.ZEOConnectionVocabulary">
       
  2134 <em class="property">class </em><code class="descclassname">pyams_utils.zodb.</code><code class="descname">ZEOConnectionVocabulary</code><span class="sig-paren">(</span><em>context=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.ZEOConnectionVocabulary" title="Permalink to this definition">¶</a></dt>
       
  2135 <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">zope.schema.vocabulary.SimpleVocabulary</span></code></p>
       
  2136 <p>ZEO connections vocabulary</p>
       
  2137 </dd></dl>
       
  2138 
       
  2139 <dl class="function">
       
  2140 <dt id="pyams_utils.zodb.get_connection">
       
  2141 <code class="descclassname">pyams_utils.zodb.</code><code class="descname">get_connection</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.get_connection" title="Permalink to this definition">¶</a></dt>
       
  2142 <dd><p>An adapter which gets a ZODB connection from a persistent object</p>
       
  2143 <p>We are assuming the object has a parent if it has been created in
       
  2144 this transaction.</p>
       
  2145 <p>Raises ValueError if it is impossible to get a connection.</p>
       
  2146 </dd></dl>
       
  2147 
       
  2148 <dl class="function">
       
  2149 <dt id="pyams_utils.zodb.get_connection_from_settings">
       
  2150 <code class="descclassname">pyams_utils.zodb.</code><code class="descname">get_connection_from_settings</code><span class="sig-paren">(</span><em>settings</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.get_connection_from_settings" title="Permalink to this definition">¶</a></dt>
       
  2151 <dd><p>Load connection matching registry settings</p>
       
  2152 </dd></dl>
       
  2153 
       
  2154 <dl class="function">
       
  2155 <dt id="pyams_utils.zodb.get_transaction_manager">
       
  2156 <code class="descclassname">pyams_utils.zodb.</code><code class="descname">get_transaction_manager</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.get_transaction_manager" title="Permalink to this definition">¶</a></dt>
       
  2157 <dd></dd></dl>
       
  2158 
       
  2159 <dl class="function">
       
  2160 <dt id="pyams_utils.zodb.handle_added_connection">
       
  2161 <code class="descclassname">pyams_utils.zodb.</code><code class="descname">handle_added_connection</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.handle_added_connection" title="Permalink to this definition">¶</a></dt>
       
  2162 <dd><p>Register new ZEO connection when added</p>
       
  2163 </dd></dl>
       
  2164 
       
  2165 <dl class="function">
       
  2166 <dt id="pyams_utils.zodb.handle_removed_connection">
       
  2167 <code class="descclassname">pyams_utils.zodb.</code><code class="descname">handle_removed_connection</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.zodb.handle_removed_connection" title="Permalink to this definition">¶</a></dt>
       
  2168 <dd><p>Un-register ZEO connection when deleted</p>
       
  2169 </dd></dl>
       
  2170 
       
  2171 </div>
       
  2172 <div class="section" id="module-pyams_utils">
       
  2173 <span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-pyams_utils" title="Permalink to this headline">¶</a></h2>
       
  2174 <dl class="function">
       
  2175 <dt id="pyams_utils.includeme">
       
  2176 <code class="descclassname">pyams_utils.</code><code class="descname">includeme</code><span class="sig-paren">(</span><em>config</em><span class="sig-paren">)</span><a class="headerlink" href="#pyams_utils.includeme" title="Permalink to this definition">¶</a></dt>
       
  2177 <dd><p>pyams_utils features include</p>
       
  2178 </dd></dl>
       
  2179 
       
  2180 </div>
       
  2181 </div>
       
  2182 
       
  2183 
       
  2184           </div>
       
  2185         </div>
       
  2186       </div>
       
  2187       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
       
  2188         <div class="sphinxsidebarwrapper">
       
  2189   <h3><a href="index.html">Table Of Contents</a></h3>
       
  2190   <ul>
       
  2191 <li><a class="reference internal" href="#">pyams_utils package</a><ul>
       
  2192 <li><a class="reference internal" href="#subpackages">Subpackages</a></li>
       
  2193 <li><a class="reference internal" href="#submodules">Submodules</a></li>
       
  2194 <li><a class="reference internal" href="#module-pyams_utils.adapter">pyams_utils.adapter module</a></li>
       
  2195 <li><a class="reference internal" href="#module-pyams_utils.attr">pyams_utils.attr module</a></li>
       
  2196 <li><a class="reference internal" href="#module-pyams_utils.container">pyams_utils.container module</a></li>
       
  2197 <li><a class="reference internal" href="#module-pyams_utils.context">pyams_utils.context module</a></li>
       
  2198 <li><a class="reference internal" href="#module-pyams_utils.data">pyams_utils.data module</a></li>
       
  2199 <li><a class="reference internal" href="#module-pyams_utils.date">pyams_utils.date module</a></li>
       
  2200 <li><a class="reference internal" href="#module-pyams_utils.decorator">pyams_utils.decorator module</a></li>
       
  2201 <li><a class="reference internal" href="#module-pyams_utils.encoding">pyams_utils.encoding module</a></li>
       
  2202 <li><a class="reference internal" href="#module-pyams_utils.html">pyams_utils.html module</a></li>
       
  2203 <li><a class="reference internal" href="#module-pyams_utils.i18n">pyams_utils.i18n module</a></li>
       
  2204 <li><a class="reference internal" href="#module-pyams_utils.include">pyams_utils.include module</a></li>
       
  2205 <li><a class="reference internal" href="#module-pyams_utils.intids">pyams_utils.intids module</a></li>
       
  2206 <li><a class="reference internal" href="#module-pyams_utils.list">pyams_utils.list module</a></li>
       
  2207 <li><a class="reference internal" href="#module-pyams_utils.lock">pyams_utils.lock module</a></li>
       
  2208 <li><a class="reference internal" href="#module-pyams_utils.progress">pyams_utils.progress module</a></li>
       
  2209 <li><a class="reference internal" href="#module-pyams_utils.property">pyams_utils.property module</a></li>
       
  2210 <li><a class="reference internal" href="#module-pyams_utils.registry">pyams_utils.registry module</a></li>
       
  2211 <li><a class="reference internal" href="#module-pyams_utils.request">pyams_utils.request module</a></li>
       
  2212 <li><a class="reference internal" href="#module-pyams_utils.schema">pyams_utils.schema module</a></li>
       
  2213 <li><a class="reference internal" href="#module-pyams_utils.session">pyams_utils.session module</a></li>
       
  2214 <li><a class="reference internal" href="#module-pyams_utils.site">pyams_utils.site module</a></li>
       
  2215 <li><a class="reference internal" href="#module-pyams_utils.size">pyams_utils.size module</a></li>
       
  2216 <li><a class="reference internal" href="#module-pyams_utils.tales">pyams_utils.tales module</a></li>
       
  2217 <li><a class="reference internal" href="#module-pyams_utils.text">pyams_utils.text module</a></li>
       
  2218 <li><a class="reference internal" href="#module-pyams_utils.traversing">pyams_utils.traversing module</a></li>
       
  2219 <li><a class="reference internal" href="#module-pyams_utils.unicode">pyams_utils.unicode module</a></li>
       
  2220 <li><a class="reference internal" href="#module-pyams_utils.url">pyams_utils.url module</a></li>
       
  2221 <li><a class="reference internal" href="#module-pyams_utils.vocabulary">pyams_utils.vocabulary module</a></li>
       
  2222 <li><a class="reference internal" href="#module-pyams_utils.wsgi">pyams_utils.wsgi module</a></li>
       
  2223 <li><a class="reference internal" href="#module-pyams_utils.zodb">pyams_utils.zodb module</a></li>
       
  2224 <li><a class="reference internal" href="#module-pyams_utils">Module contents</a></li>
       
  2225 </ul>
       
  2226 </li>
       
  2227 </ul>
       
  2228 
       
  2229 <div id="searchbox" style="display: none" role="search">
       
  2230   <h3>Quick search</h3>
       
  2231     <form class="search" action="search.html" method="get">
       
  2232       <div><input type="text" name="q" /></div>
       
  2233       <div><input type="submit" value="Go" /></div>
       
  2234       <input type="hidden" name="check_keywords" value="yes" />
       
  2235       <input type="hidden" name="area" value="default" />
       
  2236     </form>
       
  2237 </div>
       
  2238 <script type="text/javascript">$('#searchbox').show(0);</script>
       
  2239         </div>
       
  2240       </div>
       
  2241       <div class="clearer"></div>
       
  2242     </div>
       
  2243     <div class="related" role="navigation" aria-label="related navigation">
       
  2244       <h3>Navigation</h3>
       
  2245       <ul>
       
  2246         <li class="right" style="margin-right: 10px">
       
  2247           <a href="genindex.html" title="General Index"
       
  2248              >index</a></li>
       
  2249         <li class="right" >
       
  2250           <a href="py-modindex.html" title="Python Module Index"
       
  2251              >modules</a> |</li>
       
  2252         <li class="nav-item nav-item-0"><a href="index.html">PyAMS_utils 0.1.4 documentation</a> &#187;</li> 
       
  2253       </ul>
       
  2254     </div>
       
  2255     <div class="footer" role="contentinfo">
       
  2256         &#169; Copyright 2016, Thierry Florac &lt;tflorac@ulthar.net&gt;.
       
  2257       Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
       
  2258     </div>
       
  2259   </body>
       
  2260 </html>