RE: [Zope] URL quoting in python
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 [EMAIL PROTECTED] 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 ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] URL quoting in python
Thanks for the tip Duncan, I find it strange that this utility function is not in the _ namepace... time to make a trip to the Tracker. It seems like a url-encoding function should be directly accessible from zope. Thanks Kapil Duncan Booth wrote: 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 [EMAIL PROTECTED] 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 ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] URL quoting in python
Kapil Thangavelu wrote: what i am trying to do dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" url_quote dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" url_quote_plus dependent on whether you want spaces coded as + or %20 cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] URL quoting in python
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. -Original Message- From: Kapil Thangavelu [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 19, 2000 11:46 PM To: [EMAIL PROTECTED] Subject: [Zope] URL quoting in python is there a way to get a url-encoded/quoted variable in pythonish dtml ? what i am trying to do dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" Kapil ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] URL quoting in python
How about doing the equivalent on html_quote in python? Chris Chris McDonough wrote: 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. -Original Message- From: Kapil Thangavelu [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 19, 2000 11:46 PM To: [EMAIL PROTECTED] Subject: [Zope] URL quoting in python is there a way to get a url-encoded/quoted variable in pythonish dtml ? what i am trying to do dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" Kapil ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] URL quoting in python
[EMAIL PROTECTED] wrote: dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" url_quote dtml-call "RESPONSE.redirect(URL1+'?foo_bar='+foobar)" url_quote_plus Sorry, brain defect on my part: didn't notice the -call :( I see someone alerady posted what I should have said... It also fails for dtml-return... It looks like url_quote is only applicable to dtml-var...which is sort of painful. not really... how and what would you apply html_quote to in call and return (return is slightly easier) cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] URL quoting in python
Didn't happen for me (Zope 2.2b4). I got Invalid attribute name, "url_quote", for tag dtml-call "REQUEST.set('URL', URL2+'?action=Add Material Infoproduct_number='+product_number)" url_quote, on line 195 of index_html It also fails for dtml-return... It looks like url_quote is only applicable to dtml-var...which is sort of painful. Considering dtml-call has no return value which can be url_quoted, it's not all that surprising. url_quote takes action on the value rendered. Since there can by definition be nothing to render when using dtml-call, url_quote can't be supported on it. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )