[Zope-dev] What's 'section' in blocks[0] in block dtml tag?

Brett Carter brett@kavi.com
02 Jan 2001 11:54:58 -0800


Lee, I've been diddling around with the same stuff.  It took me a lot
of introspection with printing of errors via MrCreosote/Spew.  To
answer your question, 'section' is an object which contains an
attribute 'blocks'.  If you want to render the dtml in there, you can
run the 'render_blocks' method in
'<zope-instance>/lib/Python/pDocumentTemplate.py' You pass it the
section.blocks object and a mapping dictionary which is the current
namespace stack that gets passed in as the only argument to the
'render' method in you tag definition.  If you just want the raw text,
check you the render_blocks method, so you can see how they take apart
the 'section.blocks' object.  As to the object hiarchy of everything,
your guess is as good as mine as to why there's a list of tuples of
blocks wrapped in a section object, wrapped in another blocks object,
I have know idea.  Perhaps the designer of the document templates
could answer...  
-Brett


>>>>> "LEE" == LEE Kwan Soo <kslee@plaza1.snu.ac.kr> writes:

    LEE> Hi. I'm playing/struggling to make a custom block dtml tag.
    LEE> Let me call it, dtml-quote tag.
    LEE> dtml-quote tag is similar to dtml-comment tag except it will emit
    LEE> html_quoted, not rendered version of what lies 
    LEE> between <dtml-quote> ... </dtml-quote>.
    LEE> (I feel it will be usefull when I show & write some dtml examples on my
    LEE> korean zope site).

    LEE> After seeing around some python sources,
    LEE> I finally got that tname is the name of the tag, args is args, and section
    LEE> is something, in the following code.

    LEE>     def __init__(self, blocks):
    LEE>         tname, args, section = blocks[0]

    LEE> and section seems to have 6 attributes/methods:
    LEE> '__name__', '_v_blocks', '_v_cooked', '_vars', 'blocks', 'globals', 'raw'

    LEE> But that mistic raw is null string, '' and blocks is no help for me.

    LEE> How can I retrieve the raw source string enclosed in a block tag pair?

    LEE> LEE Kwan Soo.

    LEE> ps. My English is evem more cryptic this morning. Sorry I've sat up alnight play 
    LEE> Kingdom Under Fire.

    LEE> _______________________________________________
    LEE> Zope-Dev maillist  -  Zope-Dev@zope.org
    LEE> http://lists.zope.org/mailman/listinfo/zope-dev
    LEE> **  No cross posts or HTML encoding!  **
    LEE> (Related lists - 
    LEE>  http://lists.zope.org/mailman/listinfo/zope-announce
    LEE>  http://lists.zope.org/mailman/listinfo/zope )