+### historical note -- april 2014
+# the myslice chaps rightfully complained about the following discrepency
+# they found that
+# * read operations (resolve) expose stuff like e.g. 'reg-researchers', but that
+# * write operations (register, update) need e.g. 'researcher' to be set - it ignores 'reg-researchers'
+#
+# the 'normalize' helper functions below aim at ironing this out
+# however in order to break as few as possible we essentially make sure that *both* fields are set
+# upon entering the write methods (so again register and update) because some driver code
+# might depend on the presence of, say, 'researcher'
+
+# registry calls this 'reg-researchers'
+# some drivers call this 'researcher'
+# this is even more confusing as people might use 'researchers'
+def normalize_input_researcher (record):
+ # this aims at detecting a mispelled input
+ if 'researchers' in record and 'researcher' not in record:
+ record['researcher']=record['researchers']
+ del record['researchers']
+ # this looks right, use this for both keys
+ if 'reg-researchers' in record:
+ # and issue a warning if they were both set as we're overwriting some user data here
+ if 'researcher' in record:
+ logger.warning ("normalize_input_researcher: incoming record has both values, using reg-researchers")
+ record['researcher']=record['reg-researchers']
+ # we only have one key set, duplicate for the other one
+ elif 'researcher' in record:
+ logger.warning ("normalize_input_researcher: you should use 'reg-researchers' instead ot 'researcher'")
+ record['reg-researchers']=record['researcher']
+ # if at this point we still have 'researchers' it's going to be ignored and that might be confusing
+ if 'researchers' in record:
+ logger.warning ("normalize_input_researcher: incoming record has confusing 'researchers' key - ignored - use 'reg-researchers' instead")
+
+def normalize_input_record (record):
+ normalize_input_researcher (record)
+ return record
+