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
5 from zipfile import ZipFile
\r
9 def sximporter(request):
\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
16 if not os.path.exists(extract_to):
\r
17 os.makedirs(extract_to)
\r
20 f = open(os.path.join(extract_to, m), 'w')
\r
21 f.write(dump.read(m))
\r
24 #dump.extractall(extract_to, members)
\r
26 importer.sximport(extract_to, request.POST)
\r
28 return render_to_response('modules/sximporter/page.html', {
\r
30 }, context_instance=RequestContext(request))
\r