def storymap_image_list(user, id): """List storymap images """ try: key_prefix = storage.key_prefix(user['uid'], id, '_images') key_list, more = storage.list_key_names(key_prefix, 999, '') image_list = [n.split('/')[-1] for n in key_list] return jsonify({'image_list': image_list}) except storage.StorageException, e: traceback.print_exc() return jsonify({'error': str(e), 'error_detail': e.detail})
def storymap_image_list(user, id): """List storymap images """ try: key_prefix = storage.key_prefix(user["uid"], id, "_images") key_list, more = storage.list_key_names(key_prefix, 999, "") image_list = [n.split("/")[-1] for n in key_list] return jsonify({"image_list": image_list}) except storage.StorageException, e: traceback.print_exc() return jsonify({"error": str(e), "error_detail": e.detail})
def _make_storymap_id(user, title): """Get unique storymap id from slugified title""" id_set = set(user['storymaps'].keys()) # Add keys from S3 (in case of db issues) user_key_prefix = storage.key_prefix(user['uid']) regex = re.compile(r'^%s([^/]+).*' % user_key_prefix) name_list, more = storage.list_key_names(user_key_prefix, 999, '') for name in name_list: m = regex.match(name) if m: id_set.add(m.group(1)) id_base = slugify.slugify(title) id = id_base n = 0 while id in id_set: n += 1 id = '%s-%d' % (id_base, n) return id