>>>>> "Shane" == Shane Hathaway <[EMAIL PROTECTED]> writes:

    Shane> Brett Carter wrote:
    >>  >>>>> "Brett" == Brett Carter <[EMAIL PROTECTED]> writes:
    Brett> I've defined my own dtml tag (i.e. <dtml-foo></dtml-foo>)
    Brett> and I am trying to look up an object depending on the
    Brett> arguments passed to my tag.  The python class that defines
    Brett> the tag inherits from Acquisition.Implicit, but 'self'
    Brett> doesn't contain any of the Acquisition hiarchy.  It seems
    Brett> like this must be possible, since the <dtml-var> tag must
    Brett> have to do an object lookup somewhere for objects passed to
    Brett> it to render.  Can anybody shed some light on this?  Is it
    Brett> doable?  TIA -Brett
    >>  Ok, So after some *major* hacking, i've realized that the 'md'
    >> passed into the render() method of my dtml tag contains the
    >> namespace, and is of type 'TemplateDict' which appears to
    >> contain a stack of 'MultiMapping's.  Weird.  Well, anyways, I
    >> just used the 'has_key' and 'getitem' methods to lookup my
    >> item.  The question now is how do I create a new object in the
    >> current namespace?  It looks like the TemplateDict is a
    >> read-only type of data structure.  Anybody?  TIA -Brett

    Shane> Look at render() of DT_With.py.  It does an
    Shane> md._push(<mapping containing new names>) then, in a
    Shane> try/finally clause, calls DT_Util.render_blocks().  In the
    Shane> finally clause, it does md._pop().

    Shane> Shane

I'm still confused.  Ok, so render gets passed 'md', which is a
TemplateDict, which contains a MultiMapping, which looks like a stack
of dictionaries, which I am guessing is some sort of namespace stack.
So looking at the DT_with.py, it looks like, to create an object in
the current namespace, I have to wrap it in an InstanceDict, and push
it onto the 'md' using 'md._push'.  Does this also cause the new
object to be saved in the ZODB?  Or do I have to manually add it there
too?  Also, what does render_blocks do?  Why does DT_with.py's
render() return it?  Do I have to run render_blocks() to insert my new
object into the namespace?  TIA

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to