[Twisted-web] Nevow-Stan How to save file?

Suha Onay suhaonay at gmail.com
Thu Mar 13 03:16:23 EDT 2008


In the base page, I served the xxx directory for static files with the
following lines.

    def child_xxx(self, ctx):
        return static.File(os.path.join(LQS.WEB_SERVER, 'xxx'))

On the page that will serve a link to the file, the file is saved to the xxx
directory and a link is given:

f=3D open(os.path.join(LQS.WEB_SERVER, 'xxx', 'qqq.lqp'), 'w')
f.write(fileInput)
f.close()

return [
    T.a(href=3D"/xxx/qqq.lqp")['Save'],
    webform.renderForms()[FORM_LAYOUT],
]

I run this page from Firefox, IE and IE Mobile.
I want the browser open a save as dialog but it shows the file within the
browser.
How can I achieve this?

Thanks.


On Wed, Mar 12, 2008 at 7:16 PM, Adrian Perez <moebius.lists at gmail.com>
wrote:

> On Wed, 12 Mar 2008 08:55:37 +0200
> "Suha Onay" <suha at ly.com.tr> wrote:
>
> > Yes Daniel is right.
> > Sorry about the wrong question.
> > I am talking about providing a link to some downloadable content,
> > e.g., a spreadsheet or an image. How is it possible in nevow?
> >
> > On Tue, Mar 11, 2008 at 8:51 PM, L. Daniel Burr <ldanielburr at mac.com>
> > wrote:
> >
> > > On Tue, 11 Mar 2008 13:37:08 -0500, <glyph at divmod.com> wrote:
> > >
> > > >
> > > > On 04:31 pm, suhaonay at gmail.com wrote:
> > > >> I am a newbie of nevow. I want to open a save as dialog and
> > > >> enable the user
> > > >> to save files.
> > > >
> > > > Are you talking about uploading a file to the server, or saving a
> > > > file on the client?  (You can't save files on the client in a web
> > > > browser in any way that I'm aware of.)
> > > >
> > >
> > > I think the OP is talking about providing a link to some
> > > downloadable content, e.g., a spreadsheet or an image, that should
> > > trigger the browser's download behavior.
>
> You should use nevow.static.File, a quick example (save in example.tac
> and run with "twistd -noy example.tac"):
>
>  from nevow import static, appserver
>  from twisted.application import service, internet, strports
>
>  application =3D service.Application("example")
>  site =3D appserver.NevowSite(
>              resource=3Dstaic.File("thing.jpeg", "image/jpeg"))
>  server =3D strports.service("tcp:8080", site)
>  server.setServiceParent(application)
>
> You can construct a nevow.static.File passing a path to a directory,
> and you will be serving all the contents of the directory.
>
> Cheers,
>
> --
> ~
> ~
> ~
> ".signature" 4 lines, 50 characters written
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>


-- =

Suha ONAY

Likya Yaz=FDl=FDm ve Bili=FEim Hizmetleri Ltd.=DEti.
Galyum Blok No: B-08
ODT=DC Teknokent
06531 Ankara - T=FCrkiye
Tel :: (312) 210 00 90
Fax :: (312) 210 00 91
Web :: www.ly.com.tr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20080313/31=
f6d63f/attachment.htm


More information about the Twisted-web mailing list