From 2a9809df7e184d39c6b655470b4faf7aed2c16e5 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Thu, 10 Jun 2010 11:56:52 +0000 Subject: [PATCH] researchers should be researcher --- sfa/plc/api.py | 51 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/sfa/plc/api.py b/sfa/plc/api.py index cbe321b0..a75dd335 100644 --- a/sfa/plc/api.py +++ b/sfa/plc/api.py @@ -21,7 +21,47 @@ from sfa.util.namespace import * from sfa.util.api import * from sfa.util.nodemanager import NodeManager from sfa.util.sfalogging import * -from collections import defaultdict +try: + from collections import defaultdict +except: + class defaultdict(dict): + def __init__(self, default_factory=None, *a, **kw): + if (default_factory is not None and + not hasattr(default_factory, '__call__')): + raise TypeError('first argument must be callable') + dict.__init__(self, *a, **kw) + self.default_factory = default_factory + def __getitem__(self, key): + try: + return dict.__getitem__(self, key) + except KeyError: + return self.__missing__(key) + def __missing__(self, key): + if self.default_factory is None: + raise KeyError(key) + self[key] = value = self.default_factory() + return value + def __reduce__(self): + if self.default_factory is None: + args = tuple() + else: + args = self.default_factory, + return type(self), args, None, None, self.items() + def copy(self): + return self.__copy__() + def __copy__(self): + return type(self)(self.default_factory, self) + def __deepcopy__(self, memo): + import copy + return type(self)(self.default_factory, + copy.deepcopy(self.items())) + def __repr__(self): + return 'defaultdict(%s, %s)' % (self.default_factory, + dict.__repr__(self)) + + +## end of http://code.activestate.com/recipes/523034/ }}} + def list_to_dict(recs, key): """ @@ -76,6 +116,7 @@ class SfaAPI(BaseAPI): 'AuthMethod': 'password', 'AuthString': self.config.SFA_PLC_PASSWORD} + self.plshell_type = 'xmlrpc' # connect via xmlrpc url = self.config.SFA_PLC_URL @@ -135,8 +176,8 @@ class SfaAPI(BaseAPI): new_cred = Credential(subject = object_gid.get_subject()) new_cred.set_gid_caller(object_gid) new_cred.set_gid_object(object_gid) - new_cred.set_issuer(key=auth_info.get_pkey_object(), subject=auth_hrn) - new_cred.set_pubkey(object_gid.get_pubkey()) + new_cred.set_issuer_keys(auth_info.get_privkey_filename(), auth_info.get_gid_filename()) + r1 = determine_rights(type, hrn) new_cred.set_privileges(r1) @@ -424,10 +465,10 @@ class SfaAPI(BaseAPI): if (type == "slice"): # all slice users are researchers record['PI'] = [] - record['researchers'] = [] + record['researcher'] = [] for person_id in record['person_ids']: hrns = [person['hrn'] for person in persons[person_id]] - record['researchers'].extend(hrns) + record['researcher'].extend(hrns) # pis at the slice's site pl_pis = site_pis[record['site_id']] -- 2.43.0