views:

156

answers:

1

Is there a Python buildout recipe which would allow the following:

[buildout]
parts = group-of-parts

[group-of-parts]
recipe = what.can.i.use.for.this
parts = part-1 part-2

[part-1]
...

[part-2]
...

In other words, I want a recipe which takes a 'parts' attribute much like 'buildout' section does so I can manually manage a hierarchy of groups of parts.

Yes, I know that I could do:

[buildout]
parts = group-of-parts

[group-of-parts]
recipe =
parts = ${part-1:recipe} ${part-2:recipe}

[part-1]
...

[part-2]
...

but relying on the side effect that the parts will be built by referencing an attribute of them seems a bit obscure. I would rather it be more explicit by using a recipe which would just allow the name of the part itself to be listed.

Certainly when extending and overriding, it looks a lot cleaner to say:

[groups-of-parts]
parts -= part-2

than:

[groups-of-parts]
parts -= ${part-2:recipe}

Or is my problem that I am just missing something fundamental about how buildout works, or just overlooking something in the documentation which makes this much cleaner.

And no I don't want to have a flat hierarchy where all parts are listed in the 'parts' attribute of the 'buildout' section.

+1  A: 

No, there is no hierarchy, although you could build a recipe for it, of course.

Why do you want it? It's not like you end up with hundreds of parts so it's hard to keep track of them...

Lennart Regebro
Encapsulation and the ability to hide the inner detail of what is required to do something. It also aids maintainability, especially when you do have lots of parts or where an action requires a number of recipes to be combined to do something. Why should one have to go and create a special purpose recipe/egg to hide steps if composition of a multitude of other recipes can do the same job. This is all just common sense application of object oriented concepts leading to easier reuse of components. From what I have seen so far, it is an area where buildbot lacks a bit.
Graham Dumpleton
Buildout is not an object oriented programming language. I use it heavily and has yet to see a case where encapsulation or reuse of components would me meaningful.That said you can extend scripts, so I guess you can make separate scripts for the different parts, and then make a main one that extends the other parts. I doubt that's going to make anything clearer though. This is common in the Plone world, where you often has a base buildout, and then production and development buildouts.
Lennart Regebro