The data XML can be sometimes very repetitive and so we duplicate large parts. But then it becomes harder to maintain such data.
Here are some examples of repetitive data:
same access rights for different groups
same access rights for different models
the pattern form, list views and ir.action.act_window
I think we could use a template engine (Genshi) for them. Maybe we would use a different extension to differentiate with raw template or we could apply the template engine on all of them.
With such feature we could also provide function for common usage.
Another idea would be to also add templating to the view XML. But except for very rare case (like listing all the perm_ in ir.model.access), I see no real advantage and it can slow down the server.
I think it will be better to use a different extension and apply the rendering only to those file because the current parser is SAX based to consume low memory. If we pre-process all the XML files, we will slow down large data files. That’s why I think the rendering should only be done to the files that use it.
This sounds interesting, I rember that when I was on nantic we had some script to generate this records using a xml template and providing just the model name. Currently I’m not using any script but just copying and replacing the fields. For me a common template will ease the development but also the learning curve for newcomers.
I have some fear on how to avoid to much parameters on this functions, but probably this is something that should be discussed latter when implementend
I agree that using a diferent extension will be a good way to enable the feature. Maybe we can use the .txml extension (Templated XML) to indicate that the XML file contains a template.
Another option will be too look at the xml headers to see if the Genshi namespace is included on the tryton tag
Do we want to support users to define and customize custom functions (like we do for reports by overriding the get_context function) or the common usage functions will be standard?
Doubling up the extension could work, so perhaps something like .tmpl.xml (for template XML) or .gen.xml (for genshi/generate XML)? This still has the .xml extension at the end for the editior, but it is also easy to distinguish from regular XML files based on the filename when loading.
+1 to any effort that tries to simplify management of XML files.
About the proposal I wonder how hard it will be to guess the IDs that will be created by such methods. It seems that it could be somewhat harder to find the IDs that ones need to refer to in “inheriting” modules.
Although the proposal is about templating, I’ve also thought in the past about simplifying XMLs. Maybe I’m the only one but I find XMLs somewhat hard to read and write and I’ve lately been used to YAML syntax.
If that was considered there are many ways to establish the structure of such file. One of them could be as follows (a fragment of sale/sale.xml translated into sale/sale.yml):
I understand that because of the use of SAX, XML may consume less memory, and maybe others already feel comfortable with XML, but just wanted to put another option on the table.