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

Lee Harr missive at hotmail.com
Mon Apr 5 16:43:03 MDT 2004


>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


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


Thank you for your time.

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail




More information about the Twisted-web mailing list