X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/35db0410eafcdcd3bd91caeb6711bcdc20df4c4e..6ebde88b50458c1ba0d81d42ab3bc59e131537b1:/forum_modules/exporter/exporter.py?ds=sidebyside diff --git a/forum_modules/exporter/exporter.py b/forum_modules/exporter/exporter.py index f23538e..8907112 100644 --- a/forum_modules/exporter/exporter.py +++ b/forum_modules/exporter/exporter.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import os, tarfile, datetime, logging, re, ConfigParser, shutil, zipfile from django.core.cache import cache @@ -12,12 +14,6 @@ from forum import settings from django.conf import settings as djsettings import settings as selfsettings -# Try to import the with statement -try: - from __future__ import with_statement -except: - pass - CACHE_KEY = "%s_exporter_state" % APP_URL EXPORT_STEPS = [] @@ -97,8 +93,13 @@ def ET_Element_add_tag(el, tag_name, content = None, **attrs): if content: try: tag.text = unicode(content) - except: - tag.text = u'' + except Exception, e: + #logging.error('error converting unicode characters') + #import traceback + #logging.error(traceback.print_exc()) + + import string + tag.text = unicode("".join([c for c in content if c in string.printable])) for k, v in attrs.items(): tag.set(k, unicode(v)) @@ -414,7 +415,7 @@ def export_nodes(n, el, anon_data): el.add('author', n.author.id) el.add('date', make_date(n.added_at)) el.add('parent', n.parent and n.parent.id or "") - el.add('absparent', n.abs_parent and n.abs_parent or "") + el.add('absparent', n.abs_parent and n.abs_parent.id or "") act = el.add('lastactivity') act.add('by', n.last_activity_by and n.last_activity_by.id or "") @@ -450,6 +451,7 @@ def export_nodes(n, el, anon_data): rev.add('tags', ", ".join(r.tagname_list())) el.add('marked', n.marked and 'true' or 'false') + el.add('wiki', n.nis.wiki and 'true' or 'false') el.add('extraRef', n.extra_ref and n.extra_ref.id or "") make_extra(el.add('extraData'), n.extra) el.add('extraCount', n.extra_count and n.extra_count or "")