Serve a binary/static file from view callable (with paste.fileapp?)

2011-09-20 Thread Jasper
Hi everyone,

I'd like to serve a (sometimes larger) binary file from one of my
views. It seems the preferred method of doing this is with
paste.fileapp.FileApp:

http://stackoverflow.com/questions/2413707/stream-a-file-to-the-http-response-in-pylons

(see last response)

docs: http://pythonpaste.org/modules/fileapp.html

However, the code example is for pylons, and I don't think
self.start_response has any meaning in a pyramid view callable,
right? If so, I don't know what it means.

So,

1) do you indeed think this is the best way to deal with possibly
larger (non-text) files?

2) how should i use it in a pyramids view?

Thanks!

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



Re: Serve a binary/static file from view callable (with paste.fileapp?)

2011-09-20 Thread Gael Pasgrimaud
Hi,

On Tue, Sep 20, 2011 at 3:12 PM, Jasper jap...@gmail.com wrote:
 Hi everyone,

 I'd like to serve a (sometimes larger) binary file from one of my
 views. It seems the preferred method of doing this is with
 paste.fileapp.FileApp:

 http://stackoverflow.com/questions/2413707/stream-a-file-to-the-http-response-in-pylons

 (see last response)

 docs: http://pythonpaste.org/modules/fileapp.html

 However, the code example is for pylons, and I don't think
 self.start_response has any meaning in a pyramid view callable,
 right? If so, I don't know what it means.

 So,

 1) do you indeed think this is the best way to deal with possibly
 larger (non-text) files?


No, the best way is to use a real webserver like nginx with the
xsendfile module: http://wiki.nginx.org/XSendfile


 2) how should i use it in a pyramids view?


this should work:

def file_view(request):
   return request.get_response(FileApp(filename))


 Thanks!

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



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



Re: Serve a binary/static file from view callable (with paste.fileapp?)

2011-09-20 Thread Jasper van den Bosch
Thanks!

On 20 September 2011 15:42, Gael Pasgrimaud g...@gawel.org wrote:

 Hi,

 On Tue, Sep 20, 2011 at 3:12 PM, Jasper jap...@gmail.com wrote:
  Hi everyone,
 
  I'd like to serve a (sometimes larger) binary file from one of my
  views. It seems the preferred method of doing this is with
  paste.fileapp.FileApp:
 
 
 http://stackoverflow.com/questions/2413707/stream-a-file-to-the-http-response-in-pylons
 
  (see last response)
 
  docs: http://pythonpaste.org/modules/fileapp.html
 
  However, the code example is for pylons, and I don't think
  self.start_response has any meaning in a pyramid view callable,
  right? If so, I don't know what it means.
 
  So,
 
  1) do you indeed think this is the best way to deal with possibly
  larger (non-text) files?
 

 No, the best way is to use a real webserver like nginx with the
 xsendfile module: http://wiki.nginx.org/XSendfile

 
  2) how should i use it in a pyramids view?
 

 this should work:

 def file_view(request):
   return request.get_response(FileApp(filename))

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

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



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