Пример #1
0
def check_map_record(rec):
    "Check hash of given map record"
    # remove _id MongoDB Object
    if "_id" in rec:
        del rec["_id"]
    if "hash" in rec:
        md5 = rec.pop("hash")
        rec_md5 = md5hash(rec)
        if rec_md5 != md5:
            err = "Invalid hash record:\n%s\n" % json.dumps(rec)
            err += "\nrecord hash  : %s" % md5
            err += "\nobtained hash: %s\n" % md5hash(rec)
            raise Exception(err)
Пример #2
0
def check_map_record(record):
    "Check hash of given map record"
    rec = dict(record)
    # remove _id MongoDB Object
    for key in ['_id']+TRANSIENT_FIELDS:
        if  key in rec:
            del rec[key]
    if  'hash' in rec:
        md5 = rec.pop('hash')
        rec_md5 = md5hash(rec)
        if  rec_md5 != md5:
            err  = 'Invalid hash record:\n%s\n' % json.dumps(rec)
            err += '\nrecord hash  : %s' % md5
            err += '\nobtained hash: %s\n' % md5hash(rec)
            raise Exception(err)