Re: [PATCH] nevow.static.File directory listing
I was getting an infinitely recursive redirect
Actually, this patch (to nevow.static.File) will also take care of the redirect:
274c274,281 < return self.redirect(request) ---
if not request.uri.endswith('/'): self.redirect(request)
You want to return the self.redirect(request). Otherwise the DirectoryLister will still get rendered to the body of the HTTP result, to no effect.
It should probably also reuse the directoryListing() method, making the change:
if self.fp.isdir(): - return self.redirect(request) + if not request.uri.endswith('/'): + return self.redirect(request) + return self.directoryListing()
This one works for me. Without the check, it goes in to a loop and never returns anything. _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
On Sat, 2004-04-03 at 14:55, Lee Harr wrote:
I was getting an infinitely recursive redirect
Actually, this patch (to nevow.static.File) will also take care of the redirect:
274c274,281 < return self.redirect(request) ---
if not request.uri.endswith('/'): self.redirect(request)
You want to return the self.redirect(request). Otherwise the DirectoryLister will still get rendered to the body of the HTTP result, to no effect.
It should probably also reuse the directoryListing() method, making the change:
if self.fp.isdir(): - return self.redirect(request) + if not request.uri.endswith('/'): + return self.redirect(request) + return self.directoryListing()
This one works for me.
Without the check, it goes in to a loop and never returns anything.
Lee, 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? Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net Any views expressed are my own and do not necessarily reflect the views of my employer.
participants (2)
-
Lee Harr
-
Matt Goodall