[Buildbot-devel] Using dictionaries with WithProperties objects

Nicolas Alvarez nicolas.alvarez at gmail.com
Tue Dec 29 18:25:19 UTC 2009


Alexander O'Donovan-Jones wrote:
> It's a static configuration dictionary. It's used in a custom step in a
> factory. It's layout is like so:
> d = {
>  'foo' : {'var1':1, 'var2':2},
>  'bar' : {'var1':3, 'var2':4}
> }
> 
> At runtime, I want to be able to specify which of these keys in the
> dictionary it should use, and then access the values (which in this case
> is a dictionary) similar to this:
> 
> A = d[WithProperties('%(input)s')]['var1']
> B = d[WithProperties('%(input)s')]['var2']
> With the user defining 'input'.
> f.ex: if the user sets input=foo, then A==1 and B==2.
> 
> I'm doing it so that I can set specific environment variables on the
> slave.

What you need is an often-requested feature: a user-defined object/function 
that has similar behavior to WithProperties, deferring evaluation to before 
a build instead of during master.cfg parsing. Your object would return 
d[getProperty('input')] instead of getProperty('input') as WithProperties 
does.

However, the way WithProperties works, it's not at all generic. You can't do 
an object with similar behavior without hacking the buildbot guts, afaik.

-- 
Nicolas

I read mailing lists through Gmane. Please don't Cc me on replies; it makes 
me get one message on my newsreader and another on email.





More information about the devel mailing list