[Zope] DTML w/o acquisition?

Dylan Reinhardt zope@dylanreinhardt.com
Mon, 09 Dec 2002 17:04:52 -0800


Try this:

def show_stuff(self):
    """obligatory doc string"""
    return DTMLFile(file_name, globals()).__of__(self)()

Or, if you prefer, the ZPT version:

from Products.PageTemplates.PageTemplateFile import PageTemplateFile

def show_stuff(self):
    """obligatory doc string"""
    return PageTemplateFile(file_name, globals()).__of__(self)()

Trust me, you don't want to go about implementing your own templating 
system.  It sucks.

HTH,

Dylan


At 04:48 PM 12/9/2002, you wrote:
>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"
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )