+################################################################################
+
+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;
+
+################################################################################