X restore promises
After escaping strings with dumps (to avoid buildout breakage and code injection on "tricky" references, e.g. with spaces), promises started to be generated with !py! prefix in their filenames, e.g. as '!py!'\''RU1-sdr-busy.py'\''' instead of just RU1-sdr-busy.py The issue here is that our code set name = !py!'RU1-sdr-busy.py' and then monitor-promise-base from stack/monitor does output = ${directory:plugins}/${:name} which, I though, would be expanded to .../etc/plugin/RU1-sdr-busy.py but it did not deserialized the :name upon expansion. I feel like it is maybe a bug in nexedi/slapos.buildout@4e13dcb9 , but I'm not sure. Anyway, workaround the problem by generating :output ourselve also via escaped way.
-
Owner
/cc @vpelletier, @jerome
-
Owner
The behaviour you describe is known to me: the magic prefix is only checked at the beginning of value.
It has been long enough that I worked on that, and my memory of the details is nearly gone. I do not remember if it was intended as a feature (ex: "if you protect part of a value against injection, then why not protect it all ?"), or if it was only a limitation of how buildout files are interpreted: I think the variable expansion is handled differently (in standard python library's
ConfigParser
maybe ?) from where the deserialiser could be called (buildout's own code).In any case, the fix you propose here is exactly the intended way around this limitation: concatenate first, serialise second.
-
Owner
Vincent, thanks for feedback.
I though that upon seeing
name = !py!'RU1-...'
buildout initializes options withname
in internal option dict with deserialized value, and then when seeingoutput = ...${:name}
it retrieves name from that internal dict, not in raw source form used in input. Then concatenation and other operations would work as expected. In other words in my idea usingoutput = ...${:name}
is different fromoutput = ...!py!'RU1-...'
because in the second version the magic is indeed coming not in the head and automatic deserialization is not activated.In any way I do not insist on my understanding and there is no urgency with fixing anything if at all. As we all see there is a way to workaround the problem.
-
Owner
I believe the reason the internal state does not contain the raw values is that it would require extra care when annotating and/or writing out the
.installed.cfg
result: serialisation would then be required at this point. But again, my memory of this is quite vague now, so I may be reinventing the whole thing rather than actually remembering :) . -
mentioned in commit kirr/slapos@64092de9
-
mentioned in commit kirr/slapos@9f33419d
-
mentioned in commit kirr/slapos@c83fa3cb
-
Owner
@vpelletier, thanks for all the feedback back then. I do not have much to add to the discussion and I did not investigate whether
.installed.cfg
is emitted one way or another. It is a bit of shame, but I'm really tired now to check. Just for the reference this topic, and related topic of generating "safe for buildout section name" is also covered in kirr/slapos@c83fa3cb that is part of !1533 (merged).