[Zope-CMF] problems rendering ZPT in Python Script

Tres Seaver tseaver@zope.com
13 May 2002 10:50:29 -0400


On Mon, 2002-05-13 at 10:33, Gr=E9goire Weber wrote:
> Hi,
>=20
> I wanted to return a rendered ZPT by a Python Script. The result was a=20
> bit confusing to me. The skin folder contains a Python Script named=20
> 'topic_view' and a ZPT named 'topic_view_body_anon'.
>=20
> I searched the mailing list and the http://www.zopelabs.com but didn't
> find a answer.
>=20
> I get an error if I do:
>=20
>    obj =3D getattr(container, '%s%s' % (context.template_name, '_anon'))
>    html =3D obj()
>=20
>=20
> an no error (thus the rendered page) if I do:
>=20
>    obj  =3D context.topic_view_body_anon
>    html =3D obj()
>=20
> What is confusing me is that both 'obj' reference the same object
> (e.g. <ZopePageTemplate instance at 01701898>).
>=20
> What's going on?
>=20
> Any pointers?

You might try looking at the 'aq_chain' attribute of each 'obj';
sometimes the same "base" object might be wrapped differently.
OTOH, I have no idea why 'getattr' would wrap the object any
differently than 'dotted' access.

Tres.
--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com