From 4329f18589934d6fa45b6cd680d02faa86420535 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Fri, 20 Oct 2006 18:06:42 +0000 Subject: [PATCH] - add backward compatibility function --- PLC/Methods/AdmGetSiteTechContacts.py | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 PLC/Methods/AdmGetSiteTechContacts.py diff --git a/PLC/Methods/AdmGetSiteTechContacts.py b/PLC/Methods/AdmGetSiteTechContacts.py new file mode 100644 index 00000000..93a98196 --- /dev/null +++ b/PLC/Methods/AdmGetSiteTechContacts.py @@ -0,0 +1,45 @@ +from PLC.Faults import * +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Sites import Site, Sites +from PLC.Persons import Person, Persons +from PLC.Auth import PasswordAuth + +class AdmGetSiteTechContacts(Method): + """ + Deprecated. Functionality can be implemented with GetSites and + GetPersons. + + Return a list of person_ids of the technical contacts for the site + specified. + """ + + status = "deprecated" + + roles = ['admin'] + + accepts = [ + PasswordAuth(), + Mixed(Site.fields['site_id'], + Site.fields['login_base']) + ] + + returns = Site.fields['person_ids'] + + def call(self, auth, site_id_or_login_base): + # Authenticated function + assert self.caller is not None + + # Get site information + sites = Sites(self.api, [site_id_or_login_base]).values() + if not sites: + raise PLCInvalidArgument, "No such site" + + site = sites[0] + + persons = Persons(self.api, site['person_ids']).values() + + has_tech_role = lambda person: 'tech' in person['roles'] + techs = filter(has_tech_role, persons) + + return [tech['person_id'] for tech in techs] -- 2.47.0