Author: |
Camptocamp,Odoo Community Association (OCA) |
License: |
LGPL-3 |
Branch: |
14.0 |
Repository: |
acsone/edi |
Languages: |
HTML (388, 38.4%),
Python (511, 50.6%),
and
reStructuredText (111, 11.0%) |
Other repositories: |
Change2improve/edi,
ForgeFlow/edi,
OCA/edi,
TDu/edi,
akretion/edi,
aurestic/edi,
brain-tec/edi,
camptocamp/edi,
flotho/edi,
invitu/edi,
sebalix/edi,
simahawk/edi,
and
tegin/edi |
<h1 class="title">Route route handler</h1>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/endpoint_route_handler"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-endpoint_route_handler"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/226/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Technical module that provides a base handler
for adding and removing controller routes on the fly.</p>
<p>Can be used as a mixin or as a tool.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a><ul>
<li><a class="reference internal" href="#as-a-mixin" id="id2">As a mixin</a></li>
<li><a class="reference internal" href="#as-a-tool" id="id3">As a tool</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<a name="usage"></a>
<h2><a class="toc-backref" href="#id1">Usage</a></h2>
<a name="as-a-mixin"></a>
<h3><a class="toc-backref" href="#id2">As a mixin</a></h3>
<p>Use standard Odoo inheritance:</p>
<pre>
<code>class MyModel(models.Model):
_name = "my.model"
_inherit = "endpoint.route.handler"</code>
</pre>
<p>Once you have this, each <cite>my.model</cite> record will generate a route.
You can have a look at the <cite>endpoint</cite> module to see a real life example.</p>
<a name="as-a-tool"></a>
<h3><a class="toc-backref" href="#id3">As a tool</a></h3>
<p>Initialize non stored route handlers and generate routes from them.
For instance:</p>
<pre>
<code>route_handler = self.env["endpoint.route.handler"]
endpoint_handler = MyController()._my_handler
vals = {
"name": "My custom route",
"route": "/my/custom/route",
"request_method": "GET",
"auth_type": "public",
}
new_route = route_handler.new(vals)
new_route._refresh_endpoint_data() # required only for NewId records
new_route._register_controller(endpoint_handler=endpoint_handler, key="my-custom-route")</code>
</pre>
<p>Of course, what happens when the endpoint gets called
depends on the logic defined on the controller method.</p>
<p>In both cases (mixin and tool) when a new route is generated or an existing one is updated,
the <cite>ir.http.routing_map</cite> (which holds all Odoo controllers) will be updated.</p>
<p>You can see a real life example on <cite>shopfloor.app</cite> model.</p>
<a name="known-issues-roadmap"></a>
<h2><a class="toc-backref" href="#id4">Known issues / Roadmap</a></h2>
<ul class="simple">
<li>/!IMPORTANT /!when working w/ multiple workers
you MUST restart the instance every time you add or modify a route from the UI
(eg: w/ the endpoint module) otherwise is not granted that the routing map
is going to be up to date on all workers.
@simahawk as already a POC to fix this.</li>
<li>add api docs helpers</li>
<li>allow multiple HTTP methods on the same endpoint</li>
</ul>
<a name="bug-tracker"></a>
<h2><a class="toc-backref" href="#id5">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20endpoint_route_handler%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
<a name="credits"></a>
<h2><a class="toc-backref" href="#id6">Credits</a></h2>
<a name="authors"></a>
<h3><a class="toc-backref" href="#id7">Authors</a></h3>
<ul class="simple">
<li>Camptocamp</li>
</ul>
<a name="contributors"></a>
<h3><a class="toc-backref" href="#id8">Contributors</a></h3>
<ul class="simple">
<li>Simone Orsi <<a class="reference external" href="mailto:simone.orsi@camptocamp.com">simone.orsi@camptocamp.com</a>></li>
</ul>
<a name="maintainers"></a>
<h3><a class="toc-backref" href="#id9">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/simahawk"><img alt="simahawk" src="https://github.com/simahawk.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/endpoint_route_handler">OCA/edi</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>