[Zope] DTML in Product

Casey Duncan casey@zope.com
Fri, 26 Apr 2002 09:49:53 -0400


AFAICT, this should work so long as the DTMLFile is being called in the=20
context of an instance of the class that defines the name referenced from=
 the=20
dtml-var.=20

Please provide the error message and traceback. That may lend some clues.

-Casey

On Thursday 25 April 2002 08:41 am, Terry Hancock allegedly wrote:
> I'm converting a through-the-web prototype to a product.
>=20
> Following the conventions of the examples I've seen
> and the ZDG (and previous tutorials on products), I'm
> using DTML "manage_add..." forms.  However, I have
> a number of these with shared information, so it
> would be much more convenient to factor out the common
> content into a separate DTML file, which I've done.
>=20
> To be more specific, I have an add-form for my
> "GalleryArt" object, called addGalleryArt,
> which includes a file add_contrib_dtml which=20
> has a common portion of the add form used by
> several objects in the product.
>=20
> However, I can't figure out how to include the
> component DTML in the DTML form.
>=20
> I'm using DTMLFile() to get the original DTML, which
> is then registered in my __init__.py.  I've used
> the same DTMLFile() method to capture the shared
> component. So I now have a reference to add_contrib_dtml
> in the Python module which defines GalleryArt.
>=20
> Now, in order to get this into the namespace for
> the DTML form, I tried defining it like this:
>=20
> add_contrib_dtml =3D DTMLFile('dtml/add_contrib', globals())
>=20
> manage_addGalleryArt =3D DTMLFile('dtml/addGalleryArt', globals(),
> =09=09=09add_contrib_dtml=3Dadd_contrib_dtml)
>=20
> (there's a line like <dtml-var add_contrib_dtml> in
>  the dtml/addGalleryArt.dtml file).
>=20
> However, when I call this form in Zope by trying to add
> the GalleryArt object, I get an AttribError exception
> thrown from add_contrib which says it can't find "_aq_parent".
>=20
> This presumeably stands for "acquisition parent" and is
> certainly not referred to explicitly by me -- so it has
> to be something that DTML expects Zope to provide it with.
> So presumeably it did find add_contrib_dtml, but it
> isn't happy with its namespace.
>=20
> This must be because the DTML files are not in the Zope
> hierarchy, but are instead in my Product, but I then
> don't understand why the DTML forms worked in the first
> place.  SO -- the question I'm asking is how was I
> _supposed_ to do this?  (How) can I build a DTML hierarchy
> like this inside my Product?
>=20
> Thanks for any ideas!
>=20
> Terry
>=20
> --=20
> ------------------------------------------------------
> Terry Hancock
> hancock@anansispaceworks.com      =20
> Anansi Spaceworks                =20
> http://www.anansispaceworks.com=20
> ------------------------------------------------------
>=20
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>=20