--- MPIWGWeb/Attic/updatePersonalWWW.py 2007/04/26 17:02:09 1.1.2.3 +++ MPIWGWeb/Attic/updatePersonalWWW.py 2011/05/18 10:52:29 1.1.2.9 @@ -6,14 +6,17 @@ except: psyco = 1 import logging +from MPIWGHelper import unicodify, utf8ify from xml import sax from amara import saxtools - +# namespace for FileMaker8 fm_ns = 'http://www.filemaker.com/fmpxmlresult' + +# list of fields that are taken from XML and checked against DB as conflicts #checkFields=['key','first_name','last_name','title','home_inst','current_work','e_mail2'] -checkFields=['key','first_name','last_name','title','home_inst','e_mail2'] +checkFields=['key','first_name','last_name','title','titles_new','home_inst','current_work','e_mail2'] def sql_quote(v): # quote dictionary @@ -223,7 +226,7 @@ def checkImport(dsn,resultSet): keys=[] for x in results: if x[0]: - keys.append(x[0].decode('utf-8')) + keys.append(unicodify(x[0])) #first step detect new entries and conflicts @@ -289,11 +292,16 @@ def checkForConflicts(cursor,dataSet,key else: dbValue="" - setValue=dataSet[checkField] - logging.debug( " %s %s %s %s"%(repr(key),checkField,repr(dbValue),repr(setValue))) - if dbValue.strip().rstrip()!=setValue.lstrip().rstrip(): - ret.append((checkField,dbValue,setValue)) - retValue=True + if checkField in dataSet: + setValue=dataSet[checkField] + logging.debug( " %s %s %s %s"%(repr(key),checkField,repr(dbValue),repr(setValue))) + if dbValue.strip().rstrip()!=setValue.lstrip().rstrip(): + ret.append((checkField,dbValue,setValue)) + retValue=True + + else: + logging.warning("unknown field %s in data file!"%checkField) + i+=1 return retValue,ret