New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 1060236: Multi extends which set the same option, and += behaviour #22
base: master
Are you sure you want to change the base?
Conversation
…tenate the values. Proof of concept implementation for https://bugs.launchpad.net/bugs/1060236
Important note: the feature seems to introduce notable changes, and could be considered as backward incompatible. |
For me extends bases shouldn't know about each other content. I cannot see a use case when from extends you want to replace a part with a second extends. I you want this behaviour, you would prefer to do something like this :
Then |
I think this changes the expected behavior of buildout quite a bit.
If you have that config, you should end up with I don't see why you would need the "magic" behavior as described in the pull request. |
Can't you get what you want by saying Personally, I find such implicit concatenation unintuitive. What happens if both base1.cfg and base2.cfg say |
I feel the current behaviour is "magic" too ;)
My use case is to use the root buildout.cfg to deploy several components, which can collaborate, but run independantly from each other.
I could get the result I expect by moving the "parts" directive in the root buildout.cfg, i.e.: I can't get the result I expect by running buildout with several root configuration files (using the -c option), because I'd like to use the strategy recursively (higher-level components "extend" lower-level components...). That said, I understand that's a significant change. As told in https://bugs.launchpad.net/zc.buildout/+bug/1060236, my question is also: what is the use case for current implementation of multiple inheritance? I mean, why do people manage options override in multiple inheritance? And is there a way to "combine" several buildouts? |
No. As told at https://bugs.launchpad.net/zc.buildout/+bug/1060236 :
In the proposed implementation, there is a de-duplication. I mean you'll get "newest = false". Then, you are right, there is a problem if you have base1.cfg set "newest=true" and base2.cfg set "newest=false". You will get "newest = true false"... With current implementation, I defined "parts" in several bases. It generated clashes and implicit overrides. It took me time to detect the implicit overrides. It took me time to understand mutliple inheritance behaviour. I currently don't know an alternative to resolve my use case. That's why I created the ticket on Launchpad and this pull-request:
|
Thanks for working on this issue, as I had the very same troubles in a similar situation. I started looking at it a few months ago but didn't go too far due to focus change. I agree we should either alter the implementation as you suggest, or improve the documentation on the current behavior possibly explaining how to handle such a case. |
Here is another use-case example. I feel it's closer to real life:
This example shows a potential use case for multiple inheritance and highlights 2 potential issues:
As far as I understand multiple inheritance usage currently:
Are there other usages for multiple inheritance? |
Updated the pull-request branch so that it remains fast-forward. |
I'm solving it in a different way. It requires no buildout changes. It is nicely explicit, though that also might translate into "more work". It would look like this in your case: [buildout] And the doc/front/backend configs would look like this:
Such an extra |
Yes, it works. I wrote an article to summarize solutions I know: http://tech.novapost.fr/buildout-multiple-extends-en.html but I forgot to mention it in this thread. What still puzzles me in buildout inheritance mechanism is that bases inherit each other. With current implementation, "A extends B and C" is handled exactly the same as "C extends B, and A extends C". buildout/src/zc/buildout/buildout.py Line 1466 in 9e36ccb
IMHO, should be something like this:
That said, I guess this is not in the scope of this pull request. |
Or, maybe I could update the implementation proposed in this pull-request. |
I suspect the real problem here is not so much multiple inheritance but +=. I think the solution is to make += work the same as = if you don't inherit from something that includes a =. That is intuitive to me. |
I think the problem lies in this code https://github.com/buildout/buildout/blob/master/src/zc/buildout/buildout.py#L1654 += only gets looked at if two sections are being merged so a += in the base is ignored. In addition if you merge a += into a += the current merge only looks for key=, not key+=. I think if we add the following line at the top of _update_section:
|
A note about my personal status on this ticket... Short version: I am no longer planning to work on this story, so feel free to take over it. Long version: I stopped using multiple inheritance feature of zc.buildout. I used templates (jinja2) to generate a single buildout.cfg file. The single file was a bit long, but very explicit. I think it was more readable. And template engines have features like "extend" and "include" when necessary. My team was used to template engines and not to buildout inheritance, so they were more comfortable with template engines... I also tried to limit buildout usage to simple cases, i.e. do not have very long configuration files... Later, I stopped using buildout for similar reasons: my coworkers use other tools. |
b8ad13b
to
5db2e99
Compare
This pull-request is related to https://bugs.launchpad.net/zc.buildout/+bug/1060236
This is an implementation of the proposal described as first example of the ticket above:
We get
parts = base1 base2 foo
(in fact: "base1\nbase2\nfoo").If the feature is accepted, I'm ok to add more documentation if you like.