Skip to main content

Buildout parts that make you smile

Project description

missingbits

This package provides several recipes you can use if you find your self duplicating lots of config. It also has echo, which turned out to be useful for testing.

It was created for a site which uses 1, 3 or 9 zopes depending on a set of conditions.

missingbits:range

This recipe takes a string and will make a list out of it. For example, where as you could write:

[buildout]
parts = cluster

[cluster]
recipe = plone.recipe.cluster
start =
    ${buildout:bin-directory}/zope0 start
    ${buildout:bin-directory}/zope1 start
    ${buildout:bin-directory}/zope2 start
    ${buildout:bin-directory}/zope3 start
    ${buildout:bin-directory}/zope4 start
    ${buildout:bin-directory}/zope5 start
stop =
    ${buildout:bin-directory}/zope5 stop
    ${buildout:bin-directory}/zope4 stop
    ${buildout:bin-directory}/zope3 stop
    ${buildout:bin-directory}/zope2 stop
    ${buildout:bin-directory}/zope1 stop
    ${buildout:bin-directory}/zope0 stop

You can write:

[buildout]
parts = cluster

[zopes]
recipe = missingbits:range
stop = 6
cluster-start = ${{buildout:bin-directory}}/zope{0} start
cluster-stop = ${{buildout:bin-directory}}/zope{0} stop

[cluster]
recipe = plone.recipe.cluster
start = ${zopes:cluster-start.forward}
stop = ${zopes:cluster-stop.reverse}

This is most useful when the number of zopes might vary for different builds of the same site.

Parameters

start

Number to start the range at (Default: 0, Optional)

stop

Number to stop at, but not including. So start of 0 and stop of 6 will get you [0,1,2,3,4,5]. (Mandatory).

step

Number to increment by. (Default: +1, Optional)

foo

Foo is any variable you choose to set on the recipe. A number of duplicates will be made of it and a newline seperated list placed in an output variable. Any occurence of {0} will be replaced with a number for the item in the range we are up to. You can delay evaluation of any buildout variables you are using by escaping them ({{ and }}). If you don’t do this, buildout will have to evaluate them before it evaluates this recipe and you might change the order the parts run in.

foo.forward

If you set a variable called foo on the recipe, it will make a foo.forward. This contains the list in ascending order.

foo.reverse

If you set a variable called foo on the recipe, it will make a foo.reverse. This contains the list in descending order.

missingbits:clone

I don’t like copying and pasting things in buildout, i tend to make mistakes. So I clone instead.

A site with 4 zopes might look something like this:

[buildout]
parts =
    zope0
    zope1
    zope2
    zope3

[zope0]
<= instance
http-address = ${hosts:zope}:${ports:zope0}
event-log = /var/log/zope/www.foo.bar.zope0.event.log
z2-log = /var/log/zope/www.foo.bar.zope0.Z2.log

[zope1]
<= instance
http-address = ${hosts:zope}:${ports:zope1}
event-log = /var/log/zope/www.foo.bar.zope1.event.log
z2-log = /var/log/zope/www.foo.bar.zope1.Z2.log

[zope2]
<= instance
http-address = ${hosts:zope}:${ports:zope2}
event-log = /var/log/zope/www.foo.bar.zope2.event.log
z2-log = /var/log/zope/www.foo.bar.zope2.Z2.log

[zope3]
<= instance
http-address = ${hosts:zope}:${ports:zope3}
event-log = /var/log/zope/www.foo.bar.zope3.event.log
z2-log = /var/log/zope/www.foo.bar.zope3.Z2.log

When the number of zopes can change, we really need to make this more manageable. We could do this instead:

[buildout]
parts = zope-factory

[zope{0}]
<= instance
http-address = ${{hosts:zope}}:${{ports:zope{0}}}
event-log = /var/log/zope/www.foo.bar.zope{0}.event.log
z2-log = /var/log/zope/www.foo.bar.zope{0}.Z2.log

[zope-factory]
recipe = missingbits:clone
template = zope{0}
count = 4

Parameters

template

A part to use as a base for cloning. It should not be referenced in parts and it should not be reference by other parts, especially if it has a recipe. Any buildout variables it has will need to be escaped by using {{ and }}. Any occurences of {0} will be replaced by the number of the clone we are on.

start

Number to start the range at (Default: 0, Optional)

stop

Number to stop at, but not including. So start of 0 and stop of 6 will get you [0,1,2,3,4,5]. (Mandatory).

step

Number to increment by. (Default: +1, Optional)

parts

This variable is set by the recipe and contains a list of the parts that were generated. You can pass it to any recipe taking a list of parts, but you cannot pass it to ${buildout:parts} as the buildout part is evaluated too early.

missingbits:echo

While testing these recipes it was handy to have a no-op recipe that just printed some text. This is that recipe.

You can print text from your buildout like so:

[buildout]
parts = echo

[echo]
recipe = missingbits:echo
echo = Any text you want here

Repository

This software is available from our recipe repository on github.

License

Copyright 2011 Isotoma Limited

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

0.0.8 (2011-09-21)

  • Don’t reset self.name when resetting things - this works around ${:path} being invalid and the settings the stack uses shouldn’t be changing in flight - its just too weird!

0.0.7 (2011-09-15)

  • Fix optional logic

0.0.6 (2011-09-15)

  • Prior to the injection of any stack configuration, buildout._data is cleared (with the exception of the buildout and versions parts), causing any already- resolved parts to be re-resolved once the stack has been applied, and the original configuration re-applied.

0.0.5 (2011-09-09)

  • Optional config loading support

0.0.4 (2011-09-02)

  • All stacks automatically get a ‘path’ variable that points to their assets

  • Fix sibpath for namespaced modules

0.0.3 (2011-09-02)

  • Add ‘Stack’: a utility for packaging buildout as an egg.

0.0.2 (2011-08-08)

  • Fix commit missing from merge

  • Fix python2.4 support

0.0.1 (2011-08-05)

  • Add overlay recipe

0.0.0 (a long long time ago..)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

missingbits-0.0.8.zip (16.2 kB view details)

Uploaded Source

File details

Details for the file missingbits-0.0.8.zip.

File metadata

  • Download URL: missingbits-0.0.8.zip
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for missingbits-0.0.8.zip
Algorithm Hash digest
SHA256 5d4d960143c777da84efe9a56ac8aa16db343aff1e0a73260fca169e922c9aad
MD5 ee2614345ca6edc686c227747c40ac6e
BLAKE2b-256 cca33f35ef4e5b3f2f158f5eb997cb33bbbd2c3ae9474666b3e1e5cecc63040a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page