On Tuesday, July 06, 2010 11:54:34 Bob Messiaen wrote: > Hi, > > I'm having problems with downloading a large file with internet > explorer (IE8 in my case). > Once the "File download" dialog appears and you choose Save, you can > point the location where to save the file. Depending on how much time > i spend, selecting the "save to" location, my file gets only partially > saved. > > works ok with other browsers. > > The response i'm creating is not a string but a generator. > As i have spend some time looking for a solution i ran into this > article which probably has something to do with my problem: > http://www.cherrypy.org/wiki/ReturnVsYield > > Some of the code i'm using. > Controller code: > > @expose() > @handle_exception('/configuration/device/backup') > def export(self, **kwargs): > > return filedownloader(octet_stream = file_content, > filename = "test.tgz", > content_type = 'application/x-gzip') > export._cp_config = {'response.stream': True} > > filedownloader: > > from itertools import izip_longest > def grouper(n, iterable, fillvalue=None): > "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" > args = [iter(iterable)] * n > return izip_longest(fillvalue=fillvalue, *args) > > def string_chunks(octet_stream, chunck_size): > for chunk in grouper(chunck_size, octet_stream): > yield "".join(x for x in chunk if x is not None) > > def filedownloader(octet_stream, filename='output.txt', > content_type='text/plain', chunck_size=8192*2, inline=False): > addFileDownloadHeaders(content_type, filename, inline) > return string_chunks(octet_stream, chunck_size) > > I'm using CherryPy 3.1.2, Turbogears 2.1
This makes no sense to me - TG2.1 has nothing todo with Cherrypy. >From what I gather, the problem seems to occur if the generator fails. I suggest you put a proxy like tcpmon in between your browser & webapp, and see what goes over the wire. Also, what happens if you return the data at once, and what happens if you put exception-catching code around the generator, and dump whatever exception is created to some logfile. Diez -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

