+
+
+@cache.never_cache
+def xmls(request):
+ """"
+ Create a zip archive with all XML files.
+ This should be removed when we have real API.
+ """
+ temp = tempfile.TemporaryFile()
+ archive = zipfile.ZipFile(temp, 'w')
+
+ for book in models.Book.objects.all():
+ archive.write(book.xml_file.path, str('%s.xml' % book.slug))
+ archive.close()
+
+ response = HttpResponse(content_type='application/zip', mimetype='application/x-zip-compressed')
+ response['Content-Disposition'] = 'attachment; filename=xmls.zip'
+ response['Content-Length'] = temp.tell()
+
+ temp.seek(0)
+ response.write(temp.read())
+ return response
+
+
+
+# info views for API
+
+def book_info(request, id, lang='pl'):
+ book = get_object_or_404(models.Book, id=id)
+ # set language by hand
+ translation.activate(lang)
+ return render_to_response('catalogue/book_info.html', locals(),
+ context_instance=RequestContext(request))
+
+def tag_info(request, id):
+ tag = get_object_or_404(models.Tag, id=id)
+ return HttpResponse(tag.description)