On 2009-11-17 11:41:35 +1100, Martin Pool wrote:
> If I wanted to write an API client to check whether a particular user
> is a member (possibly indirectly) of a particular team (specifically
> https://edge.launchpad.net/~contributor-agreement-canonical), is there
> any simple way to do it?  A brief look a while ago seemed to show that
> I would need to manually traverse all of the teams, which seems
> inefficient...

As ubuntu-dev-tools also needs to know if a person is a member of a
team, we are using the following code for it:
,----
| def isLpTeamMember(self, team):
|     '''
|     Checks if the user is a member of a certain team on Launchpad.
|     
|     Returns True if the user is a member of the team otherwise False
| 
|     '''
|     return any(t.name == team for t in self.super_teams)
`----
(self can be a person or team object, and team is the team name we are
looking for).

Michael

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to