The report can't be reporduced later on - as the data is constantly 
changing, so I need to store the result. 

Storing the data on which the report is based is very complex and would be 
too expensive regarding storage space just for this purpose.

But I also have now found how to use StringIO and xlsxWriter here:

http://stackoverflow.com/questions/16393242/xlsxwriter-object-save-as-http-response-to-create-download-in-django

So most likely I will do it like in this sample, plus saving the report for 
later retrieval and always serving through httpresponse, so I don't need to 
expose the actual storage location via the web server.

Am Mittwoch, 2. Oktober 2013 09:36:10 UTC+2 schrieb Russell Keith-Magee:
>
>
> Well, if you need archival, there are two alternatives:
>
> 1. Write the file to disk at the same time it is being generated. There's 
> no reason you have to serve the file from where it was generated -- 
> generate it, write it, and serve it.
>
> 2. Make sure the report will always be generated the same way. An analog 
> here -- if you request a page from a web server, it probably isn't saved on 
> disk like that (unless it's a genuinely static page) -- the server knows 
> how to reproduce the same page every time you request a specific URL. Make 
> the reports the same -- if you request /report/September-2013, you generate 
> the same report every time. 
>
> The second approach depends on whether you have well time-bucketed data, 
> but it's certainly possible to do.
>
>>
>> I don't see how I could use the xlsxwriter object in the way it is 
>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-*
>> *pdf/ <https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/> - 
>> how could I pass the httpresponse object to xlsxWriter?
>> (Maybe I have not yet found how this might work - but it is not what I 
>> need anyways...)
>>
>
> I haven't used xlsxwriter myself, but the key part of the PDF example is 
> that StringIO is an object that adheres to the python File API, but doesn't 
> actually involve a file. So, you open a StringIO object, "write" to it, 
> then dump the contents as the HTTP response. 
>
> So - whatever API endpoint on xlsxwriter lets you pass in a file object -- 
> pass in a StringIO instance instead.
>
> Yours,
> Russ Magee %-)
>
>
>
> Thomas
>>
>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>
>>>
>>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom <event...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I need to create database report downloads in Excel format (via 
>>>> xlsxwriter) and I'm wondering if there is any standard or best practice as 
>>>> to where those downloads should be located.
>>>>
>>>> Especially helpful would be if there was a portable way of managing the 
>>>> file system location and web request url in a way so that I don't have to 
>>>> change settings between the development and production server.
>>>>
>>>> Is this -> 
>>>> https://docs.djangoproject.**com/en/1.5/topics/files/<https://docs.djangoproject.com/en/1.5/topics/files/>the
>>>>  way to go?
>>>>
>>>> If they're sever generated, why do they need to hit the file system at 
>>> all? 
>>>
>>> The following example in the docs:
>>>
>>> https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/<https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/>
>>>  
>>> shows how you can stream a report directly to the end user. The example 
>>> uses reportlab to produce a PDF, but the same approach will work for a tool 
>>> writing to a different format.
>>>
>>> Yours,
>>> Russ Magee %-)
>>>  
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fb0eaa54-83ab-4b68-bfbb-0702f09162ee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to