From: Tony Mack Date: Tue, 5 Jan 2010 15:47:21 +0000 (+0000) Subject: use registry manager module X-Git-Tag: sfa-0.9-8~8 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d503b9afe6f29767d1210d0d42413e7c83cbb39b;p=sfa.git use registry manager module --- diff --git a/sfa/methods/get_gids.py b/sfa/methods/get_gids.py index 444cd98e..5f1e0aab 100644 --- a/sfa/methods/get_gids.py +++ b/sfa/methods/get_gids.py @@ -11,6 +11,7 @@ from sfa.util.parameter import Parameter, Mixed from sfa.trust.auth import Auth from sfa.trust.gid import GID from sfa.trust.certificate import Certificate +from sfa.trust.credential import Credential from sfa.util.genitable import GeniTable class get_gids(Method): @@ -36,9 +37,22 @@ class get_gids(Method): def call(self, cred, hrns): # validate the credential self.api.auth.check(cred, 'getgids') - table = GeniTable() - if not isinstance(hrns, list): - hrns = [hrns] - records = table.find({'hrn': hrns}, columns=['hrn','type','gid']) - - return records + user_cred = Credential(string=cred) + origin_hrn = user_cred.get_gid_caller().get_hrn() + + # resolve the record + manager_base = 'sfa.managers' + mgr_type = self.api.config.SFA_REGISTRY_TYPE + manager_module = manager_base + ".registry_manager_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + records = manager.resolve(self.api, hrns, None, origin_hrn=origin_hrn) + if not records: + raise RecordNotFound(hrns) + + gids = [] + allowed_fields = ['hrn', 'type', 'gid'] + for record in records: + for key in record.keys(): + if key not in allowed_fields: + del(record[key]) + return records