[Zope] DTML in Product
Terry Hancock
hancock@anansispaceworks.com
Thu, 25 Apr 2002 05:41:41 -0700
I'm converting a through-the-web prototype to a product.
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.
To be more specific, I have an add-form for my
"GalleryArt" object, called addGalleryArt,
which includes a file add_contrib_dtml which
has a common portion of the add form used by
several objects in the product.
However, I can't figure out how to include the
component DTML in the DTML form.
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.
Now, in order to get this into the namespace for
the DTML form, I tried defining it like this:
add_contrib_dtml = DTMLFile('dtml/add_contrib', globals())
manage_addGalleryArt = DTMLFile('dtml/addGalleryArt', globals(),
add_contrib_dtml=add_contrib_dtml)
(there's a line like <dtml-var add_contrib_dtml> in
the dtml/addGalleryArt.dtml file).
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".
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.
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?
Thanks for any ideas!
Terry
--
------------------------------------------------------
Terry Hancock
hancock@anansispaceworks.com
Anansi Spaceworks
http://www.anansispaceworks.com
------------------------------------------------------