[Twisted-web] Re: [PATCH] nevow.static.File directory listing

Matt Goodall matt at pollenation.net
Mon Apr 5 17:39:33 MDT 2004


On Mon, 2004-04-05 at 23:43, Lee Harr wrote:
> >Aha! All becomes clear.
> >
> >>If there is a better way, I am certainly willing to use it.
> >
> >Yep, it's much simpler too :)
> >
> >Although locateChild() is the "official" API for URL traversal,
> >rend.Page adds some more convenient ways of specifying children. The one
> >you probably want is so define a child_images attribute on your root
> >page's class:
> >
> >         from twisted.application import internet, service
> >         from twisted.web import static
> >
> >         from nevow import appserver
> >         from nevow import rend
> >         from nevow import static
> >
> >         class RootPage(rend.Page):
> >
> >             # Mount the 'images' directory at the '/images' URl
> >             child_images = static.File('images')
> >
> >             docFactory = rend.htmlstr(
> >                 '''
> >                 <html>
> >                   <body>
> >                     <img src="/images/TwistedLogoFull.png" />
> >                     <p>Blah, blah, blah</p>
> >                   </body>
> >                 </html>
> >                 '''
> >                 )
> >
> >         application = service.Application('static')
> >         webServer = internet.TCPServer(
> >             8000,
> >             appserver.NevowSite(RootPage()))
> >         webServer.setServiceParent(application)
> >
> 
> 
> Ok. Cool. That looks nice.
> 
> With that example, and unpatched nevow, I still get an error when
> trying to browse to   http://localhost/images   (note, no trailing slash)
> The error is the same as in my last post ...

> File "/usr/local/lib/python2.3/site-packages/twisted/python/filepath.py", 
> line 138, in open
>     return open(self.path, mode+'b')
> exceptions.IOError: [Errno 21] Is a directory

Hmm, that's strange. Here /images is redirected to /images/ and I get a
directory list as expected. Could you paste the entire stack trace
please.

> Also... trying to get the Nevow module from anonymous cvs is giving
> me an error:
> 
> $cvs -d:pserver:anon at divmod.org:/cvs co Nevow
> cvs server: cannot find module `Nevow' - ignored
> cvs [checkout aborted]: cannot expand modules

Everything at divmod recently moved to subversion. Use the following:

	svn co svn://divmod.org/svn/Nevow/trunk Nevow


Cheers, Matt

-- 
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt at pollenation.net

Any views expressed are my own and do not necessarily reflect
the views of my employer.




More information about the Twisted-web mailing list