Hallöchen!

Dj Gilcrease writes:

> On Thu, May 20, 2010 at 12:38 AM, Lee Hinde <leehi...@gmail.com> wrote:
>
>> This is going to be a hosted solution and if I add LDAP
>> maintenance to the new things they have to do, I think they'll go
>> back to shuffling Excel files back and forth via email.  One
>> Apache log-in and then one Django log-in? Blech.  Let's see what
>> anyone else has to say...
>
> We solved this issue by having django upload the file to a
> directory that is not reachable via the web server and then server
> the files in a view. This is slower and more memory intensive then
> letting the web server handle it, but you can permission the view
> how you want and not require extra logins

I've read good things about the X-Sendfile function of Apache (newer
version of Lighty can do the same, and Nginx probably too), so I
used it.  I haven't done any benchmarking, though.

@login_required
def show_pdf(request, process_id):
    process = get_object_or_404(models.Process, 
pk=utils.convert_id_to_int(process_id))
    permissions.assert_can_view_physical_process(request.user, process)
    path = process.calculate_pdf_location()
    response = HttpResponse()
    response["X-Sendfile"] = path
    response["Content-Type"] = "application/pdf"
    response["Content-Length"] = os.path.getsize(path)
    response["Content-Disposition"] = 'attachment; 
filename="{0}.pdf"'.format(process.get_pdf_basename())
    return response

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
                                  or http://bronger-jmp.appspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to