# Having routes in the Pool

**URL:** https://discuss.tryton.org/t/having-routes-in-the-pool/9227
**Category:** Feature
**Created:** [May 8, 2026, 10:51am UTC](https://discuss.tryton.org/t/having-routes-in-the-pool/9227 "2026-05-08T10:51:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)
#### Post date: [May 8, 2026, 10:51am UTC](https://discuss.tryton.org/t/having-routes-in-the-pool/9227/1 "2026-05-08T10:51:34Z")

</div>

# Rational

As we’d like to make routes modifiable by implementors we need to put them in Pool in order to reuse the patterns people already know of register object by their ` __name__ ` in the pool and the possibility to override it in custom modules.

Another issue with the current route design is that they are available even when the module is not activated. Accessing them would result in an error but it leaks some information that might be valuable.

# Proposal

Our proposal is to add routes into the pool.

- Adding a new type in the Pool: `route`
- Objects will be registered in the Pool by their ` __name__ `
- Just like we register methods in ` __rpc__ `, those object will contain a mapping named ` __routes__ ` between a couple (`endpoint`, [HTTP Verb](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods)) and a `Route` object
- This `Route` object will represent:
  - The `name` of the method to call when accessing the route
  - A list of decorators to apply on the method (eg: `auth_required`, etc).

- The URL will be composed as follow: `/<database>/< __name__ >/<endpoint>`

At the end of the initialization of a database pool a process will define in Werkzeug all the available routes.

It might happen that a request to a route will be the event that initialize the pool (and thus the routes are not known yet), in this case instead of raising a `404`, we should initialize the pool and then replay the request.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 8, 2026, 2:11pm UTC](https://discuss.tryton.org/t/having-routes-in-the-pool/9227/2 "2026-05-08T14:11:33Z")

</div>

> [@nicoe](#):
>
> - Adding a new type in the Pool: `route`
> - Objects will be registered in the Pool by their ` __name__ `

I think those objects should be named `router` and `Router` .

> [@nicoe](#):
>
> Just like we register methods in ` __rpc__ `, those object will contain a mapping named ` __routes__ ` between a couple (`endpoint`, [HTTP Verb](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods)) and a `Route` object

I think it will be better to use the method name as key and a list of decorator as value.

> [@nicoe](#):
>
> At the end of the initialization of a database pool a process will define in Werkzeug all the available routes.

We need to remove the routes on `Pool.stop`.

> [@nicoe](#):
>
> The URL will be composed as follow: `/<database>/< __name__ >/<endpoint>`

I think it will be good to have a fixed prefix before `< __name__ >` as we have now already `rpc` and `rest`.

> [@nicoe](#):
>
> It might happen that a request to a route will be the event that initialize the pool (and thus the routes are not known yet), in this case instead of raising a `404`, we should initialize the pool and then replay the request.

It is probably simpler to have a _catch all_ route for any database and all the possible route and return a 503 with a Retry-After and initialize the pool.

---

<div class="post-metadata">

### Author: ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)
#### Post date: [June 10, 2026, 8:44am UTC](https://discuss.tryton.org/t/having-routes-in-the-pool/9227/3 "2026-06-10T08:44:03Z")

</div>

Here’s the MR: [Add routes to the Pool (!3396) · Merge requests · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/merge_requests/3396)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 14, 2026, 6:00am UTC](https://discuss.tryton.org/t/having-routes-in-the-pool/9227/4 "2026-09-14T06:00:21Z")

</div>

This topic was automatically closed after 13 days. New replies are no longer allowed.
