Dear Anthony,

Thanks for the tip. No I am able to create a file for download on the
fly.

Here's the final code.

def make_dl():
    import os

    myurl = URL('static', 'excel.txt')
    myfile = os.path.join(request.folder, 'static', 'excel.txt')
    f = open(myfile,'w')
    for i in range(20):
        f.write('This is a test %2s\n'%(i))
    f.close()
                                                       # forces
download NOT streaming
    mylink  = XML(A('clickme to download',_href=myurl+'?attachment'))
    return  dict(mylink=mylink)

Thanks again, Anthony.

Love and peace,

Joe

On Jan 19, 8:25 am, Anthony <[email protected]> wrote:
> On Thursday, January 19, 2012 11:12:53 AM UTC-5, JoeCodeswell wrote:
>
> > Dear web2py folks,
>
> > I am having trouble creating a static file on the fly.
>
> > Here is the code in dnload_file/controllers/default.py.
>
> > def make_dl():
> >     myurl = URL('static', 'excel.txt')
> >     f = open(myurl,'w')
>
> URL() generates a relative URL, but you need to generate a filesystem path,
> so try:
>
> import os
> myfile = os.path.join(request.folder, 'static', 'excel.txt')
> f = open(myfile, 'w')
>
> Anthony

Reply via email to