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

Lee Harr missive at hotmail.com
Sun Apr 4 19:03:14 MDT 2004


>Can you explain *why* you have the following code (copied from your
>original post):
>
>
>         from twisted.application import service
>         from twisted.application import internet
>
>
>         class ADir(rend.Page):
>             def locateChild(self, request, segments):
>                 path = '/'.join(segments)
>                 return static.File(path), ()
>
>
>         application = service.Application('ADirlist')
>         webservice = internet.TCPServer(
>             8080,
>             appserver.NevowSite(ADir())
>         )
>         webservice.setServiceParent(application)
>
>
>What is the use case? Why not let static.File handle everything?
>


Well... it is certainly possible that I am going about this all wrong.

I was trying to figure out how to serve images from the nevow server to
go along with my web pages. This was the first way I figured to do that.

If there is a better way, I am certainly willing to use it.

Is this code flawed in some way?  When I try to run it without that patch,
I get an error like this trying to load the root url:


2004/04/04 20:52 EDT [HTTPChannel,0,127.0.0.1] Traceback (most recent call 
last):
          File 
"/usr/local/lib/python2.3/site-packages/twisted/protocols/http.py", line 
554, in requestReceived
            self.process()
          File "/usr/local/lib/python2.3/site-packages/nevow/appserver.py", 
line 130, in process
            return self.site.getResourceFor(
          File 
"/usr/local/lib/python2.3/site-packages/twisted/internet/defer.py", line 
189, in addCallback
            callbackKeywords=kw)
          File 
"/usr/local/lib/python2.3/site-packages/twisted/internet/defer.py", line 
180, in addCallbacks
            self._runCallbacks()
        --- <exception caught here> ---
          File 
"/usr/local/lib/python2.3/site-packages/twisted/internet/defer.py", line 
313, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "/usr/local/lib/python2.3/site-packages/nevow/appserver.py", 
line 133, in <lambda>
            lambda resource: inevow.IResource(resource).renderHTTP(self)
          File "/usr/local/lib/python2.3/site-packages/nevow/static.py", 
line 290, in renderHTTP
            f = self.openForReading()
          File "/usr/local/lib/python2.3/site-packages/nevow/static.py", 
line 253, in openForReading
            return self.fp.open()
          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

2004/04/04 20:52 EDT [HTTPChannel,0,127.0.0.1] html is not a string:  None

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail




More information about the Twisted-web mailing list