def create_table(db, settings): id_size = settings['list_uuid_size'] id_size = len(gen_list_uuid(id_size)) with db.cursor as cursor: logging.info("Creating list items table if not exists...") cursor.execute(CREATE_LIST_ITEM_TABLE, (id_size, id_size)) logging.info("OK")
def add_list_item(self, parent_id, title): #WARNING: there is a nonzero chance a non-unique uuid will be generated #However the database will not allow us to insert in this case. #The chances are so low that this happening means it's very likely that #either uuid_size is way too small or the RNG is not working properly uuid = gen_list_uuid(self.uuid_size) with self.db.cursor as cursor: cursor.execute(ADD_LIST_ITEM, (uuid, parent_id, title)) items_affected = [] if parent_id is not None: items_affected += self.mark_undone(parent_id) return uuid, items_affected
def make_length_verifier(): from listrr.listid import gen_list_uuid correct_length = len(gen_list_uuid(settings['list_uuid_size'])) def lenverify(s): return len(s) == correct_length return lenverify