+################################################################################
+
+def get_or_set_uid_id (uid):
+ global uid_id_cache;
+
+ if uid_id_cache.has_key(uid):
+ return uid_id_cache[uid];
+
+ q = projectB.query("SELECT id FROM uid WHERE uid = '%s'" % (uid))
+ if not q.getresult():
+ projectB.query("INSERT INTO uid (uid) VALUES ('%s')" % (uid));
+ q = projectB.query("SELECT id FROM uid WHERE uid = '%s'" % (uid));
+ uid_id = q.getresult()[0][0];
+ uid_id_cache[uid] = uid_id;
+
+ return uid_id;
+
+################################################################################
+
+def get_or_set_fingerprint_id (fingerprint):
+ global fingerprint_id_cache;
+
+ if fingerprint_id_cache.has_key(fingerprint):
+ return fingerprint_id_cache[fingerprint]
+
+ q = projectB.query("SELECT id FROM fingerprint WHERE fingerprint = '%s'" % (fingerprint));
+ if not q.getresult():
+ projectB.query("INSERT INTO fingerprint (fingerprint) VALUES ('%s')" % (fingerprint));
+ q = projectB.query("SELECT id FROM fingerprint WHERE fingerprint = '%s'" % (fingerprint));
+ fingerprint_id = q.getresult()[0][0];
+ fingerprint_id_cache[fingerprint] = fingerprint_id;
+
+ return fingerprint_id;
+
+################################################################################