[Twisted-Python] Strange behavior with Woven, getDynamicChild, addSlash

Alex Levy mesozoic at polynode.com
Thu Jun 5 14:17:54 EDT 2003


I have two Page classes I'm trying to make play nicely, and they won't.

  class Folder(page.Page):
      def initialize(self, *args, **kwargs):
       	  self.items = kwargs.get('items', {})
      def getDynamicChild(self, name, request):
          return self.items.get(name)

  class Album(page.Page):
      # whatever...

  items = {'album': Album()}
  resource = Folder(items = items)

Straightforward enough, or so I thought.  Folder's template creates a list,
with an anchor tag for each one of its "items".  These links work fine, but
when clicked, all the children ignore the fact that addSlash=1.

So when I navigate to "/folder", it automatically redirects to "/folder/".

However, when "album" is a child returned by my Folder, navigating to
"/folder/album" does _not_ add the extra slash -- and I can't figure out
why.

Navigating manually to "/folder/album/" renders normally.  Also, the slash
is automatically added when Album is not a child of Folder, but instead its
own "base resource" in my web server's docroot.  That is, navigating to
"/album" redirects to "/album/" normally.

[The reason I'm doing this is to make a site where _every_ page shares the
same layout; even directory listings need to be templated.  Directory
listings won't always be tied to real filesystem paths, so extending
static.File seems like the wrong approach.]

Any ideas?

-- 
Alex Levy
WWW: http://mesozoic.geecs.org

"Never let your sense of morals prevent you from doing what is right."
 -- Salvor Hardin, Isaac Asimov's _Foundation_




More information about the Twisted-Python mailing list