[Zope] DTMLFile, the mysterious animal

Casey Duncan casey@zope.com
Mon, 19 Aug 2002 13:41:25 -0400


DTMLFile is a class, and is generally instantiated at import time. Passin=
g=20
arguments to the class constructor (filter=3D'Image') doesn't affect the=20
execution of the instance itself (the dtml code).

To pass arguments to the instance, you do so when you actually call it. I=
f its=20
being called from the web (a likely thing), then you can pass arguments o=
n=20
the query string (?filter=3DImage). If you cannot do this, then you must =
wrap=20
the dtml file call in another method that supplies the arguments, somethi=
ng=20
like:

main_dtml =3D DTMLFile('www/main.dtml', globals())

def main(self, context, REQUEST, **kw):
  kw['filter'] =3D 'Image'
  return self.main_dtml(context, REQUEST, **kw)

hth,

-Casey

On Monday 19 August 2002 01:19 pm, Oliver Bleutgen wrote:
> Can somebody explain to me what really happens when I have a method in=20
> my product like
> DTMLFile('www/main.dtml', globals(), filter=3D'Image').
>=20
> My problem is that I want to modify the stock main.dtml in order to sho=
w=20
> only a subset of contained objects, so I change the line
> <dtml-in objectItems ...>
> to
> <dtml-in "objectItems(filter)" ...>
>=20
> and now I get a TypeError, "object of type 'list' is not callable"
>=20
> I know that something like OrderedFolder etc. might do what I want, but=
=20
> I'm curious about what really happens here.
>=20
> cheers,
> oliver