]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/sximporter/views.py
Erroneous setting being used.
[osqa.git] / forum_modules / sximporter / views.py
1 from django.shortcuts import render_to_response\r
2 from django.template import RequestContext\r
3 from forum.views.admin import super_user_required\r
4 import importer\r
5 from zipfile import ZipFile\r
6 import os\r
7 \r
8 @super_user_required\r
9 def sximporter(request):\r
10     list = []\r
11     if request.method == "POST" and "dump" in request.FILES:\r
12         dump = ZipFile(request.FILES['dump'])\r
13         members = [f for f in dump.namelist() if f.endswith('.xml')]\r
14         extract_to = os.path.join(os.path.dirname(__file__), 'tmp')\r
15 \r
16         for m in members:\r
17             f = open(os.path.join(extract_to, m), 'w')\r
18             f.write(dump.read(m))\r
19             f.close()\r
20 \r
21         #dump.extractall(extract_to, members)\r
22         dump.close()\r
23         importer.sximport(extract_to, request.POST)\r
24 \r
25     return render_to_response('modules/sximporter/page.html', {\r
26     'names': list\r
27     }, context_instance=RequestContext(request))