In trunk! On Monday, 4 February 2013 15:05:05 UTC-6, Niphlod wrote: > > Uhm, I was just thinking to return a string instead of the open stream. > attached the patch (some refactoring bits added) > > @Paolo: turns out that wiki has it's own "download()" function to handle > files ..... in order to return cache headers you should do: > > def yourwikiindex(): > zero = request.args(0) or 'index' > if zero and zero.isdigit(): > response.headers['Cache-Control'] = 'max-age=315360000' > response.headers['Expires'] = 'Thu, 31 Dec 2037 23:59:59 GMT' > return auth.wiki() > > > > On Monday, February 4, 2013 7:34:58 PM UTC+1, Massimo Di Pierro wrote: >> >> Honestly I would like to refactor all this logic in web2py. It was >> already done for web3py: >> >> https://github.com/mdipierro/web3py/blob/master/web3py/stream.py >> >> Anyway, if you can help fix it in web2py, we can merge everything later >> >> Massimo >> >> On Monday, 4 February 2013 11:46:03 UTC-6, Paolo valleri wrote: >>> >>> I thought the same about postponing the opening of the file. Moreover, >>> just after globals:344 in the stream(...) function I have added >>> >>> if isinstance(stream, file): >>> stream_file_or_304_or_206(stream.name, >>> chunk_size=chunk_size, >>> request=request, >>> headers=headers, >>> status=self.status) >>> >>> and finally I got a 304 :-). As a result we are on the right direction, >>> although there is no reason to open the file and take only its name. We >>> need definitely something better >>> >>> >>> >>> Paolo >>> >>> >>> 2013/2/4 Niphlod <nip...@gmail.com> >>> >>>> >>>> >>>> On Monday, February 4, 2013 3:38:29 PM UTC+1, Paolo valleri wrote: >>>>> >>>>> Hi Niphlod, I am still trying to understand why the wiki uploads are >>>>> not returned as 304. >>>>> The function in charged to return either 200 or 304 is >>>>> stream_file_or_304_or_206 in streamer.py. Moreover, this function is only >>>>> called in globals.py inside stream(...). Please have a look at >>>>> globals.py:344, In order to be called the parameter 'stream' must be a >>>>> string but with 'common' downloads the stream is an open file. This is >>>>> also >>>>> documented by the comment in dal.py:9096. is what I've written correct ? >>>>> >>>> >>>> seems so, but in this case I think it should be patched (as soon as >>>> I'll get home). >>>> >>>> For downloads that on the table are merely strings (i.e. on the table >>>> there's the path to the actual file, usually in the "uploads" folder) the >>>> correct way should be to "defer" the opening of the file down the line to >>>> gluon.streamer. >>>> A lot of logic has been added to store files on pyfilesystem (and >>>> without much tests on that, I hope I won't brake anything) but I think >>>> that >>>> for default "upload" file the logic needs to be revisited. >>>> >>>> -- >>>> >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "web2py-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to web2py+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>>
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.