From: Mark Huang Date: Fri, 20 Oct 2006 18:18:13 +0000 (+0000) Subject: - fix case when caller is not able to view any PCUs X-Git-Tag: pycurl-7_13_1~497 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7dabb49e5549e1a663b10dde740b44784b703e5d;p=plcapi.git - fix case when caller is not able to view any PCUs --- diff --git a/PLC/Methods/GetPCUs.py b/PLC/Methods/GetPCUs.py index 6da58a07..1330baa1 100644 --- a/PLC/Methods/GetPCUs.py +++ b/PLC/Methods/GetPCUs.py @@ -26,19 +26,19 @@ class GetPCUs(Method): # If we are not admin, make sure to only return our own PCUs if 'admin' not in self.caller['roles']: # Get list of PCUs that we are able to view - sites = Sites(self.api, self.caller['site_ids']).values() - - valid_pcu_ids = set() - for site in sites: - valid_pcu_ids = valid_pcu_ids.union(site['pcu_ids']) + valid_pcu_ids = [] + if self.caller['site_ids']: + sites = Sites(self.api, self.caller['site_ids']).values() + for site in sites: + valid_pcu_ids += site['pcu_ids'] + pcu_ids = set(pcu_ids).intersection(valid_pcu_ids) if not pcu_ids: - pcu_ids = valid_pcu_ids - else: - pcu_ids = valid_pcu_ids.intersection(pcu_ids) + return [] pcus = PCUs(self.api, pcu_ids).values() + # Turn each PCU into a real dict pcus = [dict(pcu) for pcu in pcus] return pcus