[Zope] DTML w/o acquisition?

Terry Hancock hancock@anansispaceworks.com
Mon, 9 Dec 2002 16:48:39 -0800


If in the torrent of messages you happened to notice ;-D, I'm implementing a 
class wrapper around an SQL result within a Zope product -- this now works 
thanks to the kind suggestion by Chris McDonough. Now that the wrapping part 
works, I've exposed another problem -- the main sort of method I want is one 
that renders the data into HTML for display purposes (i.e. the object draws 
itself).

I was planning to use DTML for this, seeing as that's what's used elsewhere 
in the application. But when I try to render/run DTMLFile() methods in the 
wrapper I get complaints about acquisition failures (an error occurs in 
aq_parent()).  Now I could probably go through some hoops to make acquisition 
happen (that is, give the object an acquisition parent) -- but actually, I 
don't need it -- all the variables I want rendered are attributes of the 
wrapper class.  If I wanted to, I could give up on DTML and just use a Python 
format string.

myform = """My stuff with %(data) inserted."""  % locals()

instead of 

myform = DTMLFile("dtml/myform", globals(),  **locals())

where dtml/myform is:
"""
My stuff with &dtml-data; inserted.
"""

However, that would break the "minimize the languages" rule -- I'd now have 
to use two different template systems in the same product.  (I mainly mention 
it to prove the point that I don't need acquisition).

Can I invoke DTML w/o invoking the acquisition mechanism (or at least tell 
the acquisition mechanism not to try to find a parent for my class)?

I don't see how one could do this with DTMLFile, is there a way by actually 
invoking the DTMLMethod() constructor?

Thanks for any suggestions!
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

"Some things are too important to be taken seriously"