From 626876f896404c5b8ed10e200d95cbedc5158f5b Mon Sep 17 00:00:00 2001 From: jordan Date: Wed, 18 Apr 2012 13:49:12 +0000 Subject: [PATCH 1/1] listen for DoesNotExist exceptions when exporting user marked tags, use different method to add files to a Zip archive git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1252 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum_modules/exporter/exporter.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/forum_modules/exporter/exporter.py b/forum_modules/exporter/exporter.py index d0cc7aa..d652211 100644 --- a/forum_modules/exporter/exporter.py +++ b/forum_modules/exporter/exporter.py @@ -241,14 +241,20 @@ def export_upfiles(tf): folder = str(settings.UPFILES_FOLDER) if os.path.exists(folder): - tf.add(folder, arcname='/upfiles') + if isinstance(tf, zipfile.ZipFile): + tf.write(folder, arcname='/upfiles') + else: + tf.add(folder, arcname='/upfiles') def export_skinsfolder(tf): folder = djsettings.TEMPLATE_DIRS[0] if os.path.exists(folder): - tf.add(folder, arcname='/skins') + if isinstance(tf, zipfile.ZipFile): + tf.write(folder, arcname='/skins') + else: + tf.add(folder, arcname='/skins') def export(options, user): @@ -425,10 +431,13 @@ def export_users(u, el, anon_data): rejected = el.add('rejectedTags') for m in u.tag_selections.all(): - if m.reason == 'good': - watched.add('tag', m.tag.name) - else: - rejected.add('tag', m.tag.name) + try: + if m.reason == 'good': + watched.add('tag', m.tag.name) + else: + rejected.add('tag', m.tag.name) + except Tag.DoesNotExist: + pass -- 2.39.5