launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #03084
Exposing newCodeImport
Hi all,
I'm working on code imports so that I can script some things needed for
UDD.
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?
Does anyone know of a similar situation elsewhere that I can look at for
inspiration?
The second issue is with the "registrant" argument to
newCodeImport. This eventually becomes the owner of the created branch.
For my use case I want to specify this, as I don't want my user to own
all the branches. However, for API simplicity it shouldn't be required.
If I use @call_with(registrant=REQUEST_USER) will that prevent it from
being specified by the caller?
Is the correct solution to use @call_with() as above, but allow and
optional owner parameter that defaults to registrant?
That would solve the issue, and also prevent the registrant of the code
import being recorded as a team, so it sounds like the best solution.
In addition, I presume I need to add in access control, so that I can't
create a code import owned by any user, only teams that I am part of. Is
there an idiom for that?
Thanks,
James
Follow ups