def updateAttrInMongoDBColl(self,attrName,collName=AUTHORCLAIM_USERS_MONGODB_COLL):

        # Debug
        #conn=getMongoDBConn()
        # Must be set explicitly to JSON in order to avoid the seg fault?
        # Debug 

        # bson.errors.InvalidDocument: Cannot encode object: Liu, Xiaoming
        # print getattr(self,attrName).toJSON()
        # This works
        # getMongoDBColl('debugDictList',getMongoDBConn()).update({'a':True},{'$set':{'e':[{'a':'b'},{'c':'d'}]}},True,safe=True)
        

        #getMongoDBColl(collName,conn).update({'acisID':self.value},{'$set':{attrName:getattr(self,attrName).toJSON()}},True,safe=True)
        #conn.disconnect()

        conn=getMongoDBConn()
        try:
            getMongoDBColl(collName,conn).update({'acisID':self.value},{'$set':{attrName:getattr(self,attrName).toJSON()}},True,safe=True)
        except:
            print 'Could not update'
            raise
        conn.disconnect()
        print 'Updated'
        exit()
def getACUserRecordForNameVar(authorNameStr,conn):

    # I do not know what the ACIS string-normalization process resembles.
    #authorNameStr=sub('['+escape(punctuation)+']','',authorNameStr.lower())
    authorNameStr=normalizeAunex(authorNameStr)

    return getMongoDBColl(AUTHORCLAIM_USERS_MONGODB_COLL,conn).find_one({'nameVariations':authorNameStr})
def getACUserRecordForACISID(acisID):

    conn=getMongoDBConn()
    record=getMongoDBColl(AUTHORCLAIM_USERS_MONGODB_COLL,conn).find_one({'acisID':acisID})
    
    conn.disconnect()
    return record
    def retrieveAttrFromDBColl(self,attrName,collName=AUTHORS_MONGODB_COLL):

        conn=getMongoDBConn()
        try:
            record=getMongoDBColl(collName,conn).find_one({'name':self.value},{attrName:True})
        except:
            print 'Could not retrieve'
            raise
        if attrName in record:return record[attrName]
        conn.disconnect()
    def retrieveAttrFromDBColl(self,attrName,collName=AUTHORCLAIM_USERS_MONGODB_COLL):

        conn=getMongoDBConn()
        try:
            record=getMongoDBColl(collName,conn).find_one({'acisID':self.value},{attrName:True})
        except:
            print 'Could not retrieve the attribute',attrName,'for',self.value
            exit(1)
            #raise
        if record and (attrName in record):return record[attrName]
        conn.disconnect()
    def updateMongoDBColl(self,collName=AUTHORS_MONGODB_COLL):

        # print unicode(self.toJSON()).encode('ascii','backslashreplace')
        #print self.toJSON()

        conn=getMongoDBConn()
        try:
            return getMongoDBColl(collName,conn).update({'name':self.value},{'$set':{'name':self.value}},True,safe=True)
        except:
            print 'Could not update'
            exit()
            raise
        conn.disconnect()
        print 'Updated'
        exit()