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? Peter Armstrong _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
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
[Peter Armstrong]
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.
If the extra quote characters are literally the first and last things in the string, you could use str[1:-1] where "str" is the original value. That bit of Python syntax will chop off the first and last characters. Cheers, Tom P
participants (3)
-
Oliver Bleutgen -
Peter Armstrong -
Thomas B. Passin