[Zope] URL quoting in python
Duncan Booth
duncan@rcp.co.uk
Fri, 21 Jul 2000 10:11:35 +0000
> I often create an external method for this...
>
> em:
>
> def url_quote(s):
> import urllib
> return urllib.quote_plus(s, safe='')
>
> Silly, but it works.
>
> I think the alternative is to hack the DT_Util.py module in the
> DocumentTemplate directory to expose urllib or a derived function.
Isn't an external method a bit overkill? It is possible to just create a
DTML Method called url_quote where the body is:
<dtml-var s url_quote>
(making sure there is no whitespace before this line, and no
newline after it.)
Then from any other DTML method you just call it remembering to
pass in the parameter by name.
e.g.
<dtml-call
"RESPONSE.redirect(URL1+'?foo_bar='+url_quote(s=ufoobar))">
--
Duncan Booth duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan