[Zope] DTMLFile question

tomas@fabula.de tomas@fabula.de
Tue, 13 Aug 2002 21:15:54 +0200


Hi,

I'm trying my hands on a Zope product. The different `views' are to be
rendered with the help of dtml files, thus the class definition looks
something like:

  |class CMSResource( Traversable.Traversable, ...)
  |    "Yadda, yadda"
  |
  |    ...
  |
  |    manage_main = DTMLFile("dtml/CMSResource/main",  globals())
  |    manage_edit = DTMLFile("dtml/CMSResource/edit",  globals())
  |
  |    def __init__(self, resource):
  |      ...

So I can call on <a CMS resource>/manage_main and I get this view, etc.

The dtml/CMSResource/ directory is of course a directory delivered
with the product, it is ``part of'' the product, so to say.

Now I'd like to be lazy and try to fetch the views `as needed',
instead of declaring them as DTML class methods. Is that possible?

What I have in mind is a method

  |class CMSResource( Traversable.Traversable, ...)
  |    "Yadda, yadda"
  |
  |    ...
  |
  |    def render(name, args):
  |      my d = DTMLFile("dtml/CMSResource/" + name)
  |      return <<call d with appropriate arguments>>

enriched of course with error checking, caching of things and all that.

Whatever I've tried failed because of --as I understand-- acquisition
issues (the object returned by calling on d, like d(self, self.REQUEST)
is expected to have an aq_parent and the like somewhere in the innards
of Zope.

My understanding of Zope is not as deep as to have an idea whether what
I'm trying is possible (or rather: sensible).

Any hints?

Thanks,
-- tomas