Acquisition problems with XMLDocument?
Hi there, 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> DTML method - viewText: <!--#var standard_html_header--> <!--#var "doc[0].renderText()"--> <!--#var standard_html_footer--> 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? Regards, Martijn
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
Amos Latteier wrote:
At 03:43 PM 7/26/99 +0200, Martijn Faassen wrote:
[snip my acquisition troubles which keep biting me]
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.
Right -- I knew vaguely about this actually, but that doesn't stop me from butting my head into it anyway.
Even better, don't call it explicitly, let DTML render it,
<!--#with "doc[0]"--> <!--#var renderText--> <!--#/with-->
Yeah, that's easiest. I'll try that. Thanks! [snip]
Am I doing something wrong or is this a bug?
I think that you are doing something wrong.
You are right.
Check out the advanced DTML How-To, on DTML Method calling subtleties.
I'll take a look at that. Regards, Martijn
Hullo, I just wanted to say thanks again -- my transformation of XML (own DTD) to HTML is working excellently now, and it's easy to change how it works too! Acquisition is a wonderful thing. :) Regards, Martijn
participants (2)
-
Amos Latteier -
Martijn Faassen