[Zope] Removing " 's from strings

Oliver Bleutgen myzope@gmx.net
Tue, 20 Nov 2001 12:07:33 +0100


Peter Armstrong wrote:

> I'm trying to make an id from a string, but the string has " on each end of
> it, and I can't find a way to get rid of them in Zope.
> 
> I thought of something like:
> <dtml-call "REQUEST.set('thing', _.string.translate(thestring,
> _.string.maketrans('',''), '"'))">
> 
> But that seems to treat it as the start of a piece of text, and so then
> thinks that the dtml-let I have just before that line doesn't have a closing
> tag!
> 
> A way to use the url_quote parameter at the same time as setting it's value
> in the REQUEST thingy would be good, but I don't how to work it.
> 
> Can anyone help?


Uh, IIRC, there's some way of quoting in zope-dtml-python, though I 
don't remember what it was.
Workarounds:
Use chr(34) (the ascii code of "), or use thestring[1:-1] if the "'s are 
really at the beginning and end.
The latter could be more correct anyway, cause maybe you don't want to 
delete "'s _inside_ your string.


cheers,
oliver