1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Sites import Site, Sites
5 from PLC.Persons import Person, Persons
6 from PLC.Auth import Auth
8 class AdmGetSitePIs(Method):
10 Deprecated. Functionality can be implemented with GetSites and
13 Return a list of person_ids of the PIs for the site specified.
22 Mixed(Site.fields['site_id'],
23 Site.fields['login_base'])
26 returns = Site.fields['person_ids']
28 def call(self, auth, site_id_or_login_base):
29 # Authenticated function
30 assert self.caller is not None
32 # Get site information
33 sites = Sites(self.api, [site_id_or_login_base])
35 raise PLCInvalidArgument, "No such site"
39 persons = Persons(self.api, site['person_ids'])
41 has_pi_role = lambda person: 'pi' in person['roles']
42 pis = filter(has_pi_role, persons)
44 return [pi['person_id'] for pi in pis]