[Buildbot-devel] Using dictionaries with WithProperties objects

Dustin J. Mitchell dustin at zmanda.com
Tue Dec 29 23:22:47 UTC 2009


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]

Python's going to immediately call d.__getitem__, passing it the ds
object.  Python doesn't have any way to indicate that the __getitem__
should be "deferred" somehow.  If you were also to override the mydict
class, you could certainly *add* this behavior, but then we'd end up
with a whole class hierarchy of our own (deferrable_dict,
deferrable_set, deferrable_list, deferrable_tuple, ..), and we
wouldn't have the advantage of Python syntax for those.  you'd have to
change

  mydict = { 'a' : 'b', 'c' : 'd' }

to

  mydict = deferrable_dict('a', 'b', 'c', 'd')

All of this would get very ugly and be bug-prone and hard for new users to use.

Write a custom step.

Dustin

-- 
Open Source Storage Engineer
http://www.zmanda.com




More information about the devel mailing list