[Zope-dev] Re: Mixing recipes (zc.recipe.cmmi reuse)
Martin Aspeli
optilude at gmx.net
Mon Sep 24 17:57:59 EDT 2007
Sidnei da Silva wrote:
> My intent is:
>
> "Given any recipe, no matter where data is coming from (be it an egg
> in PyPI, a Subversion checkout or a tarball), I would like to be able
> to perform an operation in the 'local copy' of the data, without
> depending on the person that wrote the recipe to have allowed me to do
> so"
>
> An example being, after a recipe that does a Subversion checkout runs,
> my custom operation kicks in and applies a patch to the local copy
> before the buildout processing continues.
>
> I believe that this might be doable today by writing custom
> configuration, but maybe it's such a common case that could be
> simplified.
>
> Maybe something along the lines of (note: this is all pseudo-config):
>
> """
> [Step1]
> recipe = some.recipe.checkout
> url = svn://url-to-repo/package
>
> [Step2]
> recipe = zc.recipe.cmmi
> source = {Step1:location}
Do ${Step1:location}
> patch = /path/to/my/patch
>
> [zope2]
> products = {Step2:location}
> """
>
> I believe that something like this might already work today,
It does. Again, this is "just Python". You have a dict-like variable
'buildout' passed to your recipe's __init__(). This has keys for each
section, which contains a dict with keys for each option. So above, you
could address buildout['Step1']['url'], say. You can also put things
into this dict-of-dicts. Once a recipe has been run, subsequent recipes
will be able to see things put into the dict.
> if not it
> might be easy to make it work that way. But what I'm after is to avoid
> Step2 above by listing the patch to be applied in Step1 even if
> 'some.recipe.checkout' does not support the 'patch' option directly.
How would you avoid naming conflicts? How would you declare where that
option comes from? I really don't think the overhead of having to
specify a new recipe (as in your Step2 above) is very much, and it's a
lot more explicit.
> All in all, if you tell me that the hypotetical Step2 above really
> can't be avoided and that the best option is to make
> 'some.recipe.checkout' and any other recipes out support the 'patch'
> option directly, I would be fine with that too.
I'd suggest that's the best way. Only a limited number of recipes would
really need 'path' - those could re-use your patch recipe via
composition if necessary, but you have a fallback of using the recipe on
its own.
Martin
--
Acquisition is a jealous mistress
More information about the Zope-Dev
mailing list