Expose ISourcePackage.branches

Bug #352094 reported by Jonathan Lange
6
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
Muharem Hrnjadovic

Bug Description

There ought to be an API for fetching the collection of branches bound to a source package.

Related branches

Jonathan Lange (jml)
Changed in launchpad-bazaar:
importance: Undecided → High
status: New → Triaged
Revision history for this message
Jonathan Lange (jml) wrote :

This is the highest priority medium bug.

Changed in launchpad-bazaar:
importance: High → Medium
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

How does this relate to ISourcePackage.linked_branches()?
Should only official branches be returned?
How about a distro series filter?
Should this ideally return just a `SeriesSourcePackageBranch` collection?

Revision history for this message
Jonathan Lange (jml) wrote :

In order:

  - This is linked_branches, the bug title is out of date.
  - Yes.
  - No. SourcePackage has already got a distroseries associated with it. It ought to be called DistroSeriesSourcePackage.
  - No. The SSPB objects are an implementation detail and should never be exposed in any API, internal or external.

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Hmm .. interesting. IMHO the `ISeriesSourcePackageBranch` class has nothing to it that would preclude it from external exposure. Why is it banned from all APIs?

The ISourcePackage.linked_branches() method returns a collection of

   (SeriesSourcePackageBranch.pocket, Branch) tuples

which makes it difficult to declare its return type using something like @operation_returns_collection_of(). Or am I missing something?

Revision history for this message
Jonathan Lange (jml) wrote : Re: [Bug 352094] Re: Expose ISourcePackage.branches

On Fri, Oct 23, 2009 at 7:22 PM, Muharem Hrnjadovic
<email address hidden> wrote:
> Hmm .. interesting. IMHO the `ISeriesSourcePackageBranch` class has
> nothing to it that would preclude it from external exposure. Why is it
> banned from all APIs?
>

Because it's a boring implementation detail of no actual use. It's
sole purpose is to allow us to associate a mapping from pocket ->
branch with each source package.

If we weren't using an ORM, it wouldn't be a class at all.

> The ISourcePackage.linked_branches() method returns a collection of
>
>   (SeriesSourcePackageBranch.pocket, Branch) tuples
>
> which makes it difficult to declare its return type using something like
> @operation_returns_collection_of(). Or am I missing something?
>

TBH, I'm not sure why it's a list of tuples rather than a dict. I
don't know how to expose a dict over the API. Surely someone has done
it before though.

jml

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Jonathan Lange wrote:
> On Fri, Oct 23, 2009 at 7:22 PM, Muharem Hrnjadovic
> <email address hidden> wrote:
>> Hmm .. interesting. IMHO the `ISeriesSourcePackageBranch` class has
>> nothing to it that would preclude it from external exposure. Why is it
>> banned from all APIs?
>>
>
> Because it's a boring implementation detail of no actual use. It's
> sole purpose is to allow us to associate a mapping from pocket ->
> branch with each source package.

It's akin to a "linking table" in the SQL/schema modelling world and,
as such, can be very useful even to "external" users.

> If we weren't using an ORM, it wouldn't be a class at all.
>
>> The ISourcePackage.linked_branches() method returns a collection of
>>
>> (SeriesSourcePackageBranch.pocket, Branch) tuples
>>
>> which makes it difficult to declare its return type using something like
>> @operation_returns_collection_of(). Or am I missing something?
>>
>
> TBH, I'm not sure why it's a list of tuples rather than a dict. I
> don't know how to expose a dict over the API. Surely someone has done
> it before though.

That's a nice idea, construct a dict from the list of 2-tuples and
expose that in the API.

Best regards

--
Muharem Hrnjadovic <email address hidden>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC

Revision history for this message
Tim Penhey (thumper) wrote :

On Sat, 24 Oct 2009 07:22:56 Muharem Hrnjadovic wrote:
> Hmm .. interesting. IMHO the `ISeriesSourcePackageBranch` class has
> nothing to it that would preclude it from external exposure. Why is it
> banned from all APIs?
>
> The ISourcePackage.linked_branches() method returns a collection of
>
> (SeriesSourcePackageBranch.pocket, Branch) tuples
>
> which makes it difficult to declare its return type using something like
> @operation_returns_collection_of(). Or am I missing something?
>

I think all you have to do is to define that ISourcePackage inherits from
IHasBranches. That and the implementation class mixing in HasBranchesMixin.

Revision history for this message
Jonathan Lange (jml) wrote :

On Fri, Oct 23, 2009 at 8:20 PM, Muharem Hrnjadovic
<email address hidden> wrote:
> Jonathan Lange wrote:
>> On Fri, Oct 23, 2009 at 7:22 PM, Muharem Hrnjadovic
>> <email address hidden> wrote:
>>> Hmm .. interesting. IMHO the `ISeriesSourcePackageBranch` class has
>>> nothing to it that would preclude it from external exposure. Why is it
>>> banned from all APIs?
>>>
>>
>> Because it's a boring implementation detail of no actual use. It's
>> sole purpose is to allow us to associate a mapping from pocket ->
>> branch with each source package.
>
> It's akin to a "linking table" in the SQL/schema modelling world and,
> as such, can be very useful even to "external" users.
>

I know what a linking table is, but I'm still sceptical. Can you give
an example of an instance of an object representing the row in the
linking table being useful?

jml

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

OK .. I followed a recommendation of Leonard's and came up with the following solution: lp:~al-maisan/launchpad/352094

Please let me know what you think.

Changed in launchpad-code:
assignee: nobody → Muharem Hrnjadovic (al-maisan)
status: Triaged → In Progress
Changed in launchpad-code:
status: In Progress → Fix Committed
Tim Penhey (thumper)
Changed in launchpad-code:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.