[Buildbot-devel] Using dictionaries with WithProperties objects

Nicolas Alvarez nicolas.alvarez at gmail.com
Tue Dec 29 23:38:13 UTC 2009


Dustin J. Mitchell wrote:
> On Tue, Dec 29, 2009 at 5:11 PM, Nicolas Alvarez
> <nicolas.alvarez at gmail.com> wrote:
>> All we need is a DeferredString class you can put anywhere you currently
>> can use WithProperties (eg. a ShellCommand's "command" property). That
>> DeferredString would have its evaluate() method called at build time,
>> returning a string.
> 
> Right, but if you write
> 
> ds = DeferredString(foo)
> x = mydict[ds]
> 
> [... it won't work ...]

The exact same happens with mydict[WithProperties(...)] now. That wasn't the 
point.

With a generalized class, you could have a subclass that does the whole 
mydict[getProperty("foo")].

DeferredString probably needs a better name. It's not a way to return a 
hardcoded string later (eg. DeferredString("foo")). It's an object that 
buildbot gets a string from. How the object creates that string is its own 
problem.

Supposing DeferredString takes a function on its constructor (described as 
'SimpleDeferredString' in my previous email):

> ds = DeferredString(foo)
> x = mydict[ds]

would actually be written as:

x = DeferredString(lambda s: mydict[foo])

-- 
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