A silly but quick approach would be to take the fields you care about, combine them as a long string, and save them as the key of the DB_Unique object that references the original object. Each time you do DB_Unique.get_or_insert() , you must verify that the reference refers to the correct source entity, otherwise you have a duplicate. This should probably be done in a map .
Something like:
class DB_Unique(db.Model): r = db.ReferenceProperty() class DB_Obj(db.Model): a = db.IntegerProperty() b = db.StringProperty() c = db.StringProperty()
There are a few extreme cases that may occur, for example, if you have two objects with b and c equal to ('a_b', '') and ('a', 'b_') respectively, so concatenation is "a_b_" for both. so use a character you know not in your lines, not "_", or DB_Unique.r - a list of links and compare them all.
Amir
source share