Make UI helpers more easily accessible
This is an attempt to make UI helpers easier to use, in view of using them to generate Place
instances (see docs/reference/devel-blueprints/page-title-refactoring.rst
) and why not eventually also ui shortcuts, sidebar items and so on.
This would have the advantage of not having to have a module full of factory methods that needs to import basically all of Debusine's DB model types, and moving the factory methods in model-specific modules (the UI helper ones), with the additional possibility of caching.
The idea is that a collection view uses the UI helper to get the Place
instance for the parent Workspace
, and then that remains cached in the UI helper should something else need it. Neat!
This MR has two commits:
- Rename
*UIHelper
to*UI
: once I started using UI helpers, "Helper" felt like noise - Add a
ui(request)
method to models to instantiate the UI helper for that instance and request
Now, point 2 is controversial, as passing a request to a Model method feels ick to me. Looking at things in detail, what the model is doing is only picking the UI helper class and delegating everything else to it (we don't have type_traits
like C++ where we could configure helper classes corresponding to module classes in a way that typing gets it, and here I miss it), and one could argue it's a similar dependency ick as the get_absolute_url
methods.
In other words, I could swing either way, and if you end up not seeing a big problem with it, I don't want to be the obstacle on my own path