I have an URL coming out of a database like "http://www.myplace.com" and need to pass it to another website but they want it in the format of "http%3A%2F%2Fwww%2Emyplace%2Ecom". Is there a simple method to do this with or some sort of VAR tag? If not, what is the find and replace tag? Thanks, JMA
On Sat, 26 Feb 2000 Jatwood@bwanazulia.com wrote:
I have an URL coming out of a database like "http://www.myplace.com" and need to pass it to another website but they want it in the format of "http%3A%2F%2Fwww%2Emyplace%2Ecom". Is there a simple method to do this with or some sort of VAR tag? If not, what is the find and replace tag?
<dtml-var <variable holding URL> fmt=url-quote> will do most of what you want. It won't convert the dots though. Alternatively you can use the _.string module. For instance you can have DTMLMethod with id test like: <dtml-return "_.string.replace(url,'.','%2E')"> and call it from DTML or directly: http://<spamaddress>/test?url=http://www.myplace.com it will return http://www%2Emyplace%2Ecom Add a few more replace to convert all the characters you want. Pavlos
Jatwood@bwanazulia.com wrote:
I have an URL coming out of a database like "http://www.myplace.com" and need to pass it to another website but they want it in the format of "http%3A%2F%2Fwww%2Emyplace%2Ecom". Is there a simple method to do this with or some sort of VAR tag? If not, what is the find and replace tag?
The python string module (available from DTML with _.string) has many functions that let you do things like replace and map and translate. See the python docs for more info. It looks like you want to URL quote your string. There are standard python methods to do that for you also. -Michel
Thanks, JMA
_______________________________________________ Zope maillist - Zope@zope.org 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 )
participants (3)
-
Jatwoodï¼ bwanazulia.com -
Michel Pelletier -
Pavlos Christoforou