Skip to content

Instantly share code, notes, and snippets.

@edsu edsu/
Created Feb 5, 2009

What would you like to do?
def page_pdf(request, lccn, date, edition, sequence):
title = get_object_or_404(models.Title, lccn=lccn)
_year, _month, _day = date.split("-")
_date =, int(_month), int(_day))
except ValueError, e:
raise Http404
issue = title.issues.get(date_issued=_date, edition=edition)
except models.Issue.DoesNotExist, e:
raise Http404
page = issue.pages.get(sequence=int(sequence))
except models.Page.DoesNotExist, e:
raise Http404
f = file(page.pdf_abs_filename)
#content =
#return HttpResponse(content, mimetype='application/pdf')
response = HttpResponse(wsgiref.util.FileWrapper(f))
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'Attachment; filename=file.pdf'
return response
return HttpResponse(content, mimetype='application/pdf')
#return HttpResponse(wsgiref.util.FileWrapper(f), mimetype='ap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.