[Twisted-Python] Re: serving dynamic on root and still serve static somehow

ccom at gmx.net ccom at gmx.net
Tue Sep 30 13:40:38 EDT 2003

> With isLeaf=False, the root resource will _never_ have its 
> render() method called. That is because the request for 
> the root resource is always '/', not ''. 
> (i.e., "GET / HTTP/1.1", not "GET  HTTP/1.1")
> '/'.split('/') == [''], which means that getChild('', request) will
> be called. Therefore, your root resource must respond to 
> getChild('', request).

This is so tricky. Your suggestion does not work because I want to pass a
parameter for the dynamic page which I read out with request.postpath[0].

You know what would solve my problem really quickly: If I would know how to
call a child manually (or not even a child but the static.File('.')
resource). I have come up with the following code but it does throw me a " does not
return a string" error:

class Container(resource.Resource):
    isLeaf = True
    def render(self, request):        
        if request.postpath[0] == 'static':
            return self.getChild('static', request)
            return doContainer(request)

root = Container()
root.putChild('static', static.File('.'))
site = server.Site(root) 

reactor.listenTCP(8080, site)


NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++

More information about the Twisted-Python mailing list