X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/fa803e983501c159302c30e87f7f82ef8c03746b..3860fda5909f0f756be78567e4961ea82a12c4a3:/forum_modules/sximporter/views.py diff --git a/forum_modules/sximporter/views.py b/forum_modules/sximporter/views.py index fb0bcd1..95e6826 100644 --- a/forum_modules/sximporter/views.py +++ b/forum_modules/sximporter/views.py @@ -3,15 +3,25 @@ from django.template import RequestContext from forum.views.admin import super_user_required import importer from zipfile import ZipFile +import os @super_user_required def sximporter(request): list = [] if request.method == "POST" and "dump" in request.FILES: dump = ZipFile(request.FILES['dump']) - importer.sximport(dump, request.POST) + members = [f for f in dump.namelist() if f.endswith('.xml')] + extract_to = os.path.join(os.path.dirname(__file__), 'tmp') + + for m in members: + f = open(os.path.join(extract_to, m), 'w') + f.write(dump.read(m)) + f.close() + + #dump.extractall(extract_to, members) dump.close() + importer.sximport(extract_to, request.POST) return render_to_response('modules/sximporter/page.html', { - 'names': list + 'names': list }, context_instance=RequestContext(request)) \ No newline at end of file