[Buildbot-devel] Subclassing FileUpload step
Dan Savilonis
djs at n-cube.org
Wed Dec 8 18:39:16 UTC 2010
I looked at the original problem again and I think there is actually a
solution to change the constructor arguments. You just need to add
**kwargs to the constructor of the subclass and call
addFactoryArguments():
def __init__(self, build, type='continuous', **kwargs):
FileUpload.__init__(self, "foo", "bar")
self.addFactoryArguments(build=build, type=type)
Dan
On Wed, Dec 1, 2010 at 1:44 PM, Dan Savilonis <djs at n-cube.org> wrote:
> I've decided to just work around this issue for now since I don't have
> an immediate need for a custom parameter to the subclass constructor.
>
> I moved on to the second half of the problem, I tried adding a link to
> the file with self.addURL in the finished() method. This works fine,
> but the url seems to disappear upon restarting the master.
>
> Dan
>
> On Tue, Nov 30, 2010 at 2:00 PM, Dustin J. Mitchell <dustin at v.igoro.us> wrote:
>> On Tue, Nov 30, 2010 at 1:51 PM, Dan Savilonis <djs at n-cube.org> wrote:
>>> I was wondering about that. I found that matching the constructor
>>> arguments exactly makes it work. Unfortunately, that makes overriding
>>> the constructor pretty much useless, since the idea was to provide a
>>> different set of arguments. In my case, I wanted to provide a build
>>> file and type, and hide the details of the transfer that's actually
>>> occurring, as you can see in the original case I presented. Any
>>> thoughts on how I could do this?
>>
>> It was a clever way to maintain backward-compatibility of the
>> configuration file, but yes, it has had some bad consequences, too.
>>
>> Does it work to add all of the FileUpload parameters as parameters to
>> your constructor, and simply pass them along to the parent class, but
>> not specify those arguments in master.cfg?
>>
>> The other thing you could do is to override getStepFactory - so users
>> instantiate your class in master.cfg, but its getStepFactory method
>> returns a tuple (cls, kwargs) where cls is another class (maybe just
>> FileUpload) and kwargs are constructor arguments appropriate to that
>> class.
>>
>> Dustin
>>
>
More information about the devel
mailing list