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

Adrian Perez moebius.lists at gmail.com
Wed Mar 12 13:16:39 EDT 2008


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 = service.Application("example")
  site = appserver.NevowSite(
              resource=staic.File("thing.jpeg", "image/jpeg"))
  server = 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20080312/f1908170/signature.pgp


More information about the Twisted-web mailing list