[Grok-dev] Get files
zavi
osishkin at gmail.com
Sun Mar 21 09:24:54 EDT 2010
Thank you everyone for the very quick and detailed responses.
Some follow-up questions -
1. If I want to use the zope.file.download, I see here
http://svn.zope.org/zope.file/branches/ajung-blobs/src/zope/file/download.py?rev=72831&view=markup
That it is related to a browser view. Which means I have to access my grok
application using a browser, which pops up a dialog for downloading the file
etc.
Is there a way to bypass that, by having the client send a REST request with
the file name and get it directly?
I need to have grok display pages, but not always for the particaulr task of
sending files to the client.
2. Can I improve performance using sendfile()? is this integrated (or can be
integrated) to Grok in some way?
For example I managed to write a simple (non-grok) application that uses
mod_wsgi directly to work with x-sendfile. Maybe this is possible somehow
with grok?
I see there's a sendfile patch for zope2
http://gabbpuy.blogspot.com/2007/03/sendfile-patch-for-zope2.html
Can this perhaps be integrated to grok?
Thank you
wichert wrote:
>
> On 3/19/10 16:33 , Sebastian Ware wrote:
>> if you store files in src/[appname]/static they will be reachable with
>>
>> host:port/[app_instance_name]/@@/[appname]/path/relative/to/
>> static.pdf
>>
>> You can also create a view that returns files you have stored on the
>> filesystem:
>>
>> class Index(grok.View):
>> grok.name('index.html')
>> grok.require('zope.Public')
>>
>> def render(self):
>> self.response.setHeader('Content-Disposition', 'inline')
>
> You probably want to provide a filename with that header as well.
>
>> self.response.setHeader('Content-Type',
>> self.context.content_type)
>> file = open('local/file/system/path.pdf', 'rb')
>> data = file.read()
>> file.close()
>>
>> return data
>
> This works, but a performance killer when serving large files since
> you'll keep a thread blocked during the download. You should to able to
> return a file iterator instead.
>
> Wichert.
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>
>
--
View this message in context: http://old.nabble.com/Get-files-tp27947412p27976132.html
Sent from the Grok mailing list archive at Nabble.com.
More information about the Grok-dev
mailing list