Is there any reason that Folders aren't callable?

That is, you can't directly render a folder with <dtml-var
nameofafolder>. You have to do something like <dtml-var
"nameofafolder.index_html(_.None, _)">. But, that's not quite the same
because if the folder lacks an index_html, it gets acquired.

Here's an extra method that can be added to lib/python/OFS/, or
to, to make Folders render nicely.

    # XXX hack to make folders render
    #     retains compatibility with current behaviour
    #     if the folder doesn't contain index_html
    def __call__(self, *args, **kw):
        """ mandatory docstring """
        index = self._getOb('index_html', default=None)
        if index is not None:
            args = (self,) + tuple(args[1:])
            return apply(index, args, kw)
        return ''

Is this a good idea? Should this go into the Collector as an RFE with

Actually, I'm not sure why it should be tuple(args[1:]) -- I just copied
that out of ZCallable in the latest PTK CVS. I'd guess you'd want to
check the first argument (client) for whether it is None before
replacing it with self.

Perhaps something like this:

  args = (len(args)>0 and args[0] or self,) + tuple(args[1:])

Discussion welcomed.

Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to