Hi, Is it possible, and how, to mimmic the "<dtml-var ... html_quote>" statement in a Python script using "print ..." ?? Thanks, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net
Hi Thierry, Thierry FLORAC wrote:
Hi,
Is it possible, and how, to mimmic the "<dtml-var ... html_quote>" statement in a Python script using "print ..." ??
Thanks,
Thierry
just make a new python script and stare at the example source already in it :-) Especially the first "import" statement would be of interest. Regards Tino
It's all written in the source :-) This is the html_quote method used by dtml (lib/python/DocumenTemplate/html_quote.py) # split off into its own module for aliasing without circrefs from cgi import escape from ustr import ustr def html_quote(v, name='(Unknown name)', md={}): return escape(ustr(v), 1) I think also urllib can help you: import urllib print urllib.quote('this is a string') Best regards Petter Enholm -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of Thierry FLORAC Sent: 12. juni 2003 11:39 To: zope@zope.org Subject: [Zope] html_quote in Python script Hi, Is it possible, and how, to mimmic the "<dtml-var ... html_quote>" statement in a Python script using "print ..." ?? Thanks, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Hi, Petter Enhom wrote:
It's all written in the source :-)
This is the html_quote method used by dtml (lib/python/DocumenTemplate/html_quote.py)
# split off into its own module for aliasing without circrefs
from cgi import escape from ustr import ustr
def html_quote(v, name='(Unknown name)', md={}): return escape(ustr(v), 1)
Its all written in front of you when you start writing a new python script in Zope: # Example code: # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote ^ ^ ^ ^ ^ ^
I think also urllib can help you:
import urllib print urllib.quote('this is a string')
erm. but this is a different thing. html_quoting means put & into -> &, put < into < and so on. url_quote means put " " into %20, ... BTW (hint! hint!) for alle the URL constructors out there: from ZTUtils import make_query query=make_query(foo='bar',blah=[1,2,3]) will build a nice query string to be appendet to URLs. Regards Tino
participants (3)
-
Petter Enhom -
Thierry FLORAC -
Tino Wildenhain