X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Fregistry_manager.py;h=5567197d050662c4618c8dfcacc2a34803255961;hb=ecc85e0b923922cf7117d29b380f5284edb88f21;hp=cc5654a6be6bc983d54d05ec1c12d64a0a3c2dbe;hpb=32020b2567795112be0435ecaff9455804a0c018;p=sfa.git diff --git a/sfa/managers/registry_manager.py b/sfa/managers/registry_manager.py index cc5654a6..5567197d 100644 --- a/sfa/managers/registry_manager.py +++ b/sfa/managers/registry_manager.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import types # for get_key_from_incoming_ip import tempfile @@ -42,7 +44,7 @@ from sqlalchemy.orm.collections import InstrumentedList # e.g. registry calls this 'reg-researchers' # while some drivers call this 'researcher' # we need to make sure that both keys appear and are the same -def _normalize_input (record, reg_key, driver_key): +def _normalize_input(record, reg_key, driver_key): # this looks right, use this for both keys if reg_key in record: # and issue a warning if they were both set and different @@ -229,7 +231,7 @@ class RegistryManager: # used to be in the driver code, sounds like a poorman thing though def solve_neighbour_url (record): if not record.type.startswith('authority'): return - hrn=record.hrn + hrn = record.hrn for neighbour_dict in [ api.aggregates, api.registries ]: if hrn in neighbour_dict: record.url=neighbour_dict[hrn].get_url() @@ -295,12 +297,11 @@ class RegistryManager: # logger.debug("non recursive mode, found {} local records".format(len(records))) # so that sfi list can show more than plain names... for record in records: - # xxx mystery - again this useless statement is key here so that - # resulting records have their __dict__ field actually in line with the - # object's contents; was first observed with authorities' 'name' column + # xxx mystery - see also the bottom of model.py + # resulting records have been observed to not always have + # their __dict__ actually in line with the object's contents; + # was first observed with authorities' 'name' column # that would be missing from result as received by client - # record.todict() is the place where __dict__ is used - print "DO NOT REMOVE ME before augment_with_sfa_builtins, record={}".format(record) augment_with_sfa_builtins(record) record_dicts = [ record.record_to_dict(exclude_types=(InstrumentedList,)) for record in records ] @@ -499,11 +500,16 @@ class RegistryManager: record.email = email # update the PLC information that was specified with the record - # xxx mystery: oddly enough, without this useless statement, + # xxx mystery -- see also the bottom of model.py, + # oddly enough, without this useless statement, # record.__dict__ as received by the driver seems to be off - # anyway the driver should receive an object + # anyway the driver should receive an object # (and then extract __dict__ itself if needed) - print "DO NOT REMOVE ME before driver.update, record={}".format(record) + print("DO NOT REMOVE ME before driver.update, record={}".format(record)) + # as of June 2015: I suspect we could remove that print line above and replace it with + # augment_with_sfa_builtins(record) + # instead, that checks for these fields, like it is done above in List() + # but that would need to be confirmed by more extensive tests new_key_pointer = -1 try: (pointer, new_key_pointer) = api.driver.update (record.__dict__, new_record.__dict__, hrn, new_key) @@ -619,7 +625,7 @@ class RegistryManager: for command in all_commands: (status, output) = commands.getstatusoutput(command) if status: - raise Exception, output + raise Exception(output) for filename in [key_filename, gid_filename]: os.unlink(filename)