[Zope-dev] Acquisition problems with XMLDocument?

Amos Latteier amos@aracnet.com
Mon, 26 Jul 1999 10:51:53 -0700


At 03:43 PM 7/26/99 +0200, Martijn Faassen wrote:
>I'm having some trouble getting acquisition to work with XMLDocuments.
>When
>calling some part of an XML doc by URL acquisition works, but when
>calling it in Python it doesn't (or I don't get it). I get name errors.
>
>Example:
>
>XMLDocument - doc:
><?xml version="1.0"?>
><text>This is text</text>
>
>DTML method - renderText:
><p>
><!--#var "text_content()"-->
></p>

Hmm, why not <!--#var text_content-->

>DTML method - viewText:
><!--#var standard_html_header-->
><!--#var "doc[0].renderText()"-->
><!--#var standard_html_footer-->

Hmm. You are calling a DTML Method with no arguments. In general if you
call a DTML Method explicitly you should provide a client and a mapping
argument.

Even better, don't call it explicitly, let DTML render it,

<!--#with "doc[0]"-->
<!--#var renderText-->
<!--#/with-->

>When I access renderText as follows, it works:
>
>.../doc/0/renderText
>
>However, when I use viewText instead, it gives a NameError (text_content
>unknown). So acquisition is in fact doing something (as renderText is
>indeed called), but then it seems to forget the namespace context?
>
>Am I doing something wrong or is this a bug?

I think that you are doing something wrong.

Check out the advanced DTML How-To, on DTML Method calling subtleties.

  http://www.zope.org/Documentation/HowTo/DTML

Good luck!

-Amos