Hi together What can I do if I whould return html code frome a external method? It always quote the return string Mit freundlichen Grüssen Roger Ineichen ___________________________ Projekt01 GmbH www.projekt01.ch Langackerstrasse 8 6330 Cham phone +41 (0)41 781 01 78 mobile +41 (0)79 340 52 32 fax +41 (0)41 781 00 78 email r.ineichen@projekt01.ch ___________________________ END OF MESSAGE
Projekt01, Roger Ineichen writes:
What can I do if I whould return html code frome a external method? It always quote the return string It seems that you are calling your external method from ZPT.
In this case, you must use "structure" in from of your call. Dieter
Thanks Dieter you're knowledge are really great. I found also a answer in a document called Zope Page Templates: "Advanced Usage" from digital creations a example usage of structure ____________________________ Inserting Structure Normally, the tal:replace and tal:content statements quote the text that they insert, converting < to <, for instance. If you actually want to insert the unquoted text, you need to precede the expression with the structure keyword. Given a variable copyright, the following two lines: <span tal:replace="copyright">Copyright 2000</span> <span tal:replace="structure copyright">Copyright 2000</span> ...might generate "© 2001 By <b>Me</b>" and "© 2001 By Me" respectively. This feature is especially useful when you are inserting a fragment of HTML that is stored in a property or generated by another Zope object. For instance, you may have news items that contain simple HTML markup such as bold and italic text when they are rendered, and you want to preserve this when inserting them into a "Top News" page. In this case, you might write: <p tal:repeat="article topnewsitems" tal:content="structure article">A News Article</p> Mit freundlichen Grüssen Roger Ineichen ___________________________ Projekt01 GmbH www.projekt01.ch Langackerstrasse 8 6330 Cham phone +41 (0)41 781 01 78 mobile +41 (0)79 340 52 32 fax +41 (0)41 781 00 78 email r.ineichen@projekt01.ch ___________________________ END OF MESSAGE
-----Ursprüngliche Nachricht----- Von: Dieter Maurer [mailto:dieter@handshake.de] Gesendet: Mittwoch, 23. Oktober 2002 20:31 An: r.ineichen@projekt01.ch Cc: zope@zope.org Betreff: Re: [Zope] Exsternal method quote
Projekt01, Roger Ineichen writes:
What can I do if I whould return html code frome a external method? > It always quote the return string It seems that you are calling your external method from ZPT.
In this case, you must use "structure" in from of your call.
Dieter
On Wed, 23 Oct 2002, Dieter Maurer wrote:
Projekt01, Roger Ineichen writes:
What can I do if I whould return html code frome a external method? It always quote the return string It seems that you are calling your external method from ZPT.
In this case, you must use "structure" in from of your call. Is there any equivalent for this for Python Scripts?
For certain reasons I use a script which returns a complete HTML-page. This Script calls another Script which parses some parameters and returns the contents of a file object of the ZODB. I plan to convert these files to structured text for easier user handling but currently this file contains HTML. I observed that also in a python script all HTML is quoted. Any hint how to prevent that? Kind regards Andreas.
Andreas Tille writes:
On Wed, 23 Oct 2002, Dieter Maurer wrote:
Projekt01, Roger Ineichen writes:
What can I do if I whould return html code frome a external method? It always quote the return string It seems that you are calling your external method from ZPT.
In this case, you must use "structure" in from of your call. Is there any equivalent for this for Python Scripts? The same way:
ZPT doesn't care how a value is produced (by a External Method, a Script, a function call or a literal). Dieter
On Thu, 24 Oct 2002, Dieter Maurer wrote:
In this case, you must use "structure" in from of your call. Is there any equivalent for this for Python Scripts? The same way:
ZPT doesn't care how a value is produced (by a External Method, a Script, a function call or a literal). Sorry, you missunderstood the question. I do not use any ZPT. My main pythons script returns some kind of
"""<html> <head> ... </head> <body> ... </body> </html>""" The problem is that another Python Script inside the body part should return the contents of a File Object which should be inserted verbatim as it is. But the HTML-flags are quotet and I really see no reason for this. I could provide an example but if I make it as simple as possible to show the problem I wonder whether people might ask why I'm doing useless stuff instead of using ZPT or DTML. Kind regards Andreas.
Andreas Tille writes:
... The problem is that another Python Script inside the body part should return the contents of a File Object which should be inserted verbatim as it is. But the HTML-flags are quotet and I really see no reason for this. You say that a Python Script automatically quotes HTML which comes from a plain file object?
I do not want to believe this!
I could provide an example but if I make it as simple as possible to show the problem I wonder whether people might ask why I'm doing useless stuff instead of using ZPT or DTML. Please provide a minimal example (in a small zexp). I am curious where the HTML quoting happens...
Dieter
On Fri, 25 Oct 2002, Dieter Maurer wrote:
You say that a Python Script automatically quotes HTML which comes from a plain file object?
I do not want to believe this! Hmm, me too, to be honest.
Please provide a minimal example (in a small zexp). I am curious where the HTML quoting happens... To prevent posting binaries to this list I putted it on
http://people.debian.org/~tille/quoting.zexp Explanation: If I do return cont[foundname] in the last line of index_html the HTML-Stuff is quoted. If I replace this by return cont[foundname].document_src() it is not quoted but can only be viewed by authenticated users - i.e. a passwort identification has to be passed which is not acceptable for this case. Thanks for your interest Andreas.
Andreas Tille writes:
On Fri, 25 Oct 2002, Dieter Maurer wrote:
You say that a Python Script automatically quotes HTML which comes from a plain file object?
I do not want to believe this! Hmm, me too, to be honest.
Please provide a minimal example (in a small zexp). I am curious where the HTML quoting happens... To prevent posting binaries to this list I putted it on
http://people.debian.org/~tille/quoting.zexp
Explanation:
If I do
return cont[foundname]
in the last line of index_html the HTML-Stuff is quoted. If I replace this by
return cont[foundname].document_src() This seems not to be a "File" object but something else, maybe a DTML object.
With "return cont[foundname]", you return the object itself. ZPublisher converts this to a string by calling its "__str__" method. DTML objects perform HTML quoting in their "__str__" method. "File" objects, on the other hand, return raw content.
it is not quoted but can only be viewed by authenticated users - i.e. a passwort identification has to be passed which is not acceptable for this case. You can use a proxy role on the script.
You may also call your DTML object to get the rendered (and not HTML quoted) result (be careful, to pass the necessary positional parameters, unless the object does not really contain DTML commands). Dieter
On Mon, 28 Oct 2002, Dieter Maurer wrote:
This seems not to be a "File" object but something else, maybe a DTML object. Damn, your are right.
With "return cont[foundname]", you return the object itself. ZPublisher converts this to a string by calling its "__str__" method. DTML objects perform HTML quoting in their "__str__" method.
"File" objects, on the other hand, return raw content. Thanks for opening my eyes!
Kind regards Andreas.
participants (3)
-
Andreas Tille -
Dieter Maurer -
Projekt01, Roger Ineichen