]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/sximporter/views.py
More data handled by the exporter, and a improved "pickled" value parsing.
[osqa.git] / forum_modules / sximporter / views.py
index fb0bcd1bbf3a4e16bb8739a58e1b77eb3c085197..95e6826ca497ba43dc93b4a6378b8d524500a5af 100644 (file)
@@ -3,15 +3,25 @@ from django.template import RequestContext
 from forum.views.admin import super_user_required\r
 import importer\r
 from zipfile import ZipFile\r
+import os\r
 \r
 @super_user_required\r
 def sximporter(request):\r
     list = []\r
     if request.method == "POST" and "dump" in request.FILES:\r
         dump = ZipFile(request.FILES['dump'])\r
-        importer.sximport(dump, request.POST)\r
+        members = [f for f in dump.namelist() if f.endswith('.xml')]\r
+        extract_to = os.path.join(os.path.dirname(__file__), 'tmp')\r
+\r
+        for m in members:\r
+            f = open(os.path.join(extract_to, m), 'w')\r
+            f.write(dump.read(m))\r
+            f.close()\r
+\r
+        #dump.extractall(extract_to, members)\r
         dump.close()\r
+        importer.sximport(extract_to, request.POST)\r
 \r
     return render_to_response('modules/sximporter/page.html', {\r
-        'names': list\r
+    'names': list\r
     }, context_instance=RequestContext(request))
\ No newline at end of file