← Back to team overview

launchpad-dev team mailing list archive

Adapters & API (was Re: Exposing newCodeImport)

 

On Sun, Mar 28, 2010 at 9:58 PM, James Westby <jw+debian@xxxxxxxxxxxxxxx> wrote:
> On Mon, 29 Mar 2010 08:05:30 +1300, Michael Hudson <michael.hudson@xxxxxxxxxxxxx> wrote:
>> > I've got it to the stage where I have IBranchTarget.newCodeImport() and
>> > I want to expose this method over the API. I have two questions about
>> > how to do that though.
>> >
>> > However, I can't simply expose it, as it isn't on the actual branch
>> > targets. I'd like to know what the best way to do this is.
>> >
>> > IBranchTarget has several implementations, one for each of product,
>> > sourcepackage, person, and productseries. I want the method to be only
>> > available on the first two if possible, but it's fine if it has to be
>> > all four, as it is part of the interface after all.
>> >
>> > I can add newCodeImport methods to IProduct and ISourcePackage that just
>> > do
>> >
>> >     def newCodeImport(...):
>> >         return IBranchTarget(self).newCodeImport(...)
>> >
>> > but that seems like unnecessary duplication.
>> >
>> > Is there some way that I can tell lazr.restful to consider IBranchTarget
>> > when looking at what to export on IProduct etc?
>>
>> I *think* but without checking the code or really knowing for sure that
>> you have to make IProduct inherit from IBranchTarget to do this.  But
>> IIRC products are not IBranchTargets, they are adaptable to
>> IBranchTargets, and I don't think adaptation is (or really could be) a
>> concept that translates into the API.
>
> Right, so it sounds like I still need a small interface and mixin to do
> the adaptation and call newCodeImport on the result?
>

This is the right solution given our current constraints, but it's kind of ugly.

I know there's a bunch of stuff to do with the webservice API first,
but do we have any idea how we can have methods on interfaces where
they make sense and still expose them over the webservice API?

jml



Follow ups