def show_list(list_name): """Renders the markdown file corresponding to list_name""" list_path = os.path.join(DROPBOX_LIST_FOLDER, list_name + ".md") try: new_rev = listsdotmd.get_file_rev(db_client, list_path) except ErrorResponse: abort(404) app.logger.error("Couldn't get file rev for: %s", list_name) list_in_redis = r.get(list_name) if list_in_redis: list_in_redis = json.loads(list_in_redis) if not list_in_redis or "rev" not in list_in_redis or (new_rev != list_in_redis["rev"]): try: list_str = listsdotmd.load_list_as_string(db_client, list_path) except ErrorResponse: abort(404) app.logger.error("Couldn't load list from Dropbox: %s", list_name) r.set(list_name, json.dumps({"data": list_str, "rev": new_rev})) else: list_str = list_in_redis["data"] print "List %s loaded from redis" % list_name try: list_html = listsdotmd.convert_list_to_html(list_str) except MarkdownError: abort(404) app.logger.error("Couldn't convert markdown file to HTML: %s", list_name) return render_template("list.html", list_markup=list_html)
def test_get_file_rev(self): db_client = MockDropboxClient() self.assertEqual(listsdotmd.get_file_rev(db_client, '/list1.md'), '362e2029684fe')