%PDF- %PDF-
Direktori : /usr/share/doc/python3-routes/html/modules/ |
Current File : //usr/share/doc/python3-routes/html/modules/route.html |
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <title>routes.route – Route — Routes 2.5.0 documentation</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> <link rel="stylesheet" type="text/css" href="../_static/classic.css" /> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> <script src="../_static/doctools.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="routes.middleware – Routes WSGI Middleware" href="middleware.html" /> <link rel="prev" title="routes.mapper – Mapper and Sub-Mapper" href="mapper.html" /> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="middleware.html" title="routes.middleware – Routes WSGI Middleware" accesskey="N">next</a> |</li> <li class="right" > <a href="mapper.html" title="routes.mapper – Mapper and Sub-Mapper" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Routes 2.5.0 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Routes Modules</a> »</li> <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.route</span></code> – Route</a></li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="module-routes.route"> <span id="routes-route-route"></span><h1><a class="reference internal" href="#module-routes.route" title="routes.route"><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.route</span></code></a> – Route<a class="headerlink" href="#module-routes.route" title="Permalink to this headline">¶</a></h1> <section id="module-contents"> <h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalink to this headline">¶</a></h2> <dl class="py class"> <dt class="sig sig-object py" id="routes.route.Route"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">routes.route.</span></span><span class="sig-name descname"><span class="pre">Route</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">routepath</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route" title="Permalink to this definition">¶</a></dt> <dd><p>The Route object holds a route recognition and generation routine.</p> <p>See Route.__init__ docs for usage.</p> <p>Initialize a route, with a given routepath for matching/generation</p> <p>The set of keyword args will be used as defaults.</p> <p>Usage:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">routes.base</span> <span class="kn">import</span> <span class="n">Route</span> <span class="gp">>>> </span><span class="n">newroute</span> <span class="o">=</span> <span class="n">Route</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s1">':controller/:action/:id'</span><span class="p">)</span> <span class="gp">>>> </span><span class="nb">sorted</span><span class="p">(</span><span class="n">newroute</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> <span class="go">[('action', 'index'), ('id', None)]</span> <span class="gp">>>> </span><span class="n">newroute</span> <span class="o">=</span> <span class="n">Route</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s1">'date/:year/:month/:day'</span><span class="p">,</span> <span class="gp">... </span> <span class="n">controller</span><span class="o">=</span><span class="s2">"blog"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"view"</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">newroute</span> <span class="o">=</span> <span class="n">Route</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s1">'archives/:page'</span><span class="p">,</span> <span class="n">controller</span><span class="o">=</span><span class="s2">"blog"</span><span class="p">,</span> <span class="gp">... </span> <span class="n">action</span><span class="o">=</span><span class="s2">"by_page"</span><span class="p">,</span> <span class="n">requirements</span> <span class="o">=</span> <span class="p">{</span> <span class="s1">'page'</span><span class="p">:</span><span class="s1">'\d{1,2}'</span> <span class="p">})</span> <span class="gp">>>> </span><span class="n">newroute</span><span class="o">.</span><span class="n">reqs</span> <span class="go">{'page': '\\d{1,2}'}</span> </pre></div> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Route is generally not called directly, a Mapper instance connect method should be used to add routes.</p> </div> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.buildfullreg"> <span class="sig-name descname"><span class="pre">buildfullreg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">clist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.buildfullreg" title="Permalink to this definition">¶</a></dt> <dd><p>Build the regexp by iterating through the routelist and replacing dicts with the appropriate regexp match</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.buildnextreg"> <span class="sig-name descname"><span class="pre">buildnextreg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.buildnextreg" title="Permalink to this definition">¶</a></dt> <dd><p>Recursively build our regexp given a path, and a controller list.</p> <p>Returns the regular expression string, and two booleans that can be ignored as they’re only used internally by buildnextreg.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="routes.route.Route.done_chars"> <span class="sig-name descname"><span class="pre">done_chars</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">('/',</span> <span class="pre">',',</span> <span class="pre">';',</span> <span class="pre">'.',</span> <span class="pre">'#')</span></em><a class="headerlink" href="#routes.route.Route.done_chars" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.generate"> <span class="sig-name descname"><span class="pre">generate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">_ignore_req_list</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">_append_slash</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.generate" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a URL from ourself given a set of keyword arguments</p> <p>Toss an exception if this set of keywords would cause a gap in the url.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.generate_minimized"> <span class="sig-name descname"><span class="pre">generate_minimized</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">kargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.generate_minimized" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a minimized version of the URL</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.generate_non_minimized"> <span class="sig-name descname"><span class="pre">generate_non_minimized</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">kargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.generate_non_minimized" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a non-minimal version of the URL</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.make_full_route"> <span class="sig-name descname"><span class="pre">make_full_route</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.make_full_route" title="Permalink to this definition">¶</a></dt> <dd><p>Make a full routelist string for use with non-minimized generation</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.make_unicode"> <span class="sig-name descname"><span class="pre">make_unicode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.make_unicode" title="Permalink to this definition">¶</a></dt> <dd><p>Transform the given argument into a unicode string.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.makeregexp"> <span class="sig-name descname"><span class="pre">makeregexp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">clist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.makeregexp" title="Permalink to this definition">¶</a></dt> <dd><p>Create a regular expression for matching purposes</p> <p>Note: This MUST be called before match can function properly.</p> <p>clist should be a list of valid controller strings that can be matched, for this reason makeregexp should be called by the web framework after it knows all available controllers that can be utilized.</p> <p>include_names indicates whether this should be a match regexp assigned to itself using regexp grouping names, or if names should be excluded for use in a single larger regexp to determine if any routes match</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="routes.route.Route.match"> <span class="sig-name descname"><span class="pre">match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">environ</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sub_domains</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sub_domains_ignore</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain_match</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#routes.route.Route.match" title="Permalink to this definition">¶</a></dt> <dd><p>Match a url to our regexp.</p> <p>While the regexp might match, this operation isn’t guaranteed as there’s other factors that can cause a match to fail even though the regexp succeeds (Default that was relied on wasn’t given, requirement regexp doesn’t pass, etc.).</p> <p>Therefore the calling function shouldn’t assume this will return a valid dict, the other possible return is False if a match doesn’t work out.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="routes.route.Route.reserved_keys"> <span class="sig-name descname"><span class="pre">reserved_keys</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">['requirements']</span></em><a class="headerlink" href="#routes.route.Route.reserved_keys" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> </section> </section> <div class="clearer"></div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.route</span></code> – Route</a><ul> <li><a class="reference internal" href="#module-contents">Module Contents</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="mapper.html" title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.mapper</span></code> – Mapper and Sub-Mapper</a></p> <h4>Next topic</h4> <p class="topless"><a href="middleware.html" title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.middleware</span></code> – Routes WSGI Middleware</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/modules/route.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="middleware.html" title="routes.middleware – Routes WSGI Middleware" >next</a> |</li> <li class="right" > <a href="mapper.html" title="routes.mapper – Mapper and Sub-Mapper" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Routes 2.5.0 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >Routes Modules</a> »</li> <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">routes.route</span></code> – Route</a></li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2005-2022, Ben Bangert, Mike Orr, and numerous contributers. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2. </div> </body> </html>