From 826888465397ef8915b3a4a538ad26dff08d2625 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 20 Jun 2011 21:01:05 -0500 Subject: [PATCH 1/2] Fix cleaned_markdown_conversion so that it doesn't bork on empty strings Basically, clean_html would throw an error on '', so we just return '' "if not text" --- mediagoblin/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mediagoblin/util.py b/mediagoblin/util.py index 0e43a1f5..e964324f 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -383,6 +383,11 @@ def cleaned_markdown_conversion(text): """ Take a block of text, run it through MarkDown, and clean its HTML. """ + # Markdown will do nothing with and clean_html can do nothing with + # an empty string :) + if not text: + return u'' + return clean_html(MARKDOWN_INSTANCE.convert(text)) From a2c37d0a78f939ee208225840f83a90fd698aedf Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 20 Jun 2011 21:02:46 -0500 Subject: [PATCH 2/2] Only migrate to description_html if description also exists. --- mediagoblin/db/migrations.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index b87988fe..aacbf079 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -40,7 +40,8 @@ class MediaEntryMigration(DocumentMigration): Now that we can have rich descriptions via Markdown, we should update all existing entries to record the rich description versions. """ - self.target = {'description_html': {'$exists': False}} + self.target = {'description_html': {'$exists': False}, + 'description': {'$exists': True}} if not self.status: for doc in self.collection.find(self.target):