Dynamically adding a value to an assembly configuration

I am looking to fill in a value in the zc.buildout configuration, evaluating certain criteria. For instance,

if fqdn endswith '.net' then hostname = this_pkg_server else hostname = that_pkg_server

I am looking to create a specific site configuration. I can evaluate fqdn with a macro, but how to populate this value in the configuration?

thanks

+5
source share
1 answer

The simplest answer is to use the wonderful mr.scripty .

PyPI page:

Unconfirmed example:

 [buildout] parts = hostname [hostname] recipe=mr.scripty pkg_server= ... import os ... if os.environ.get('HOSTNAME', '').endswith('.net'): ... return 'this_pkg_server' ... return 'that_pkg_server' 

Then you can use the return value in your build as ${hostname:pkg_server} .

There is a more complex solution, i.e. Create your own build recipe. It is not so simple, but efforts may not be practical.

+6
source

All Articles