zope string question, easy for pythonistas
Hi all, I'm trying to compare an AUTHENTICATED_USER string to a variable which I named '2nd_smr' in this script to determine if it should be bolded in a big table and stick out for the user: <dtml-if "_.string.lower(_.str( AUTHENTICATED_USER)) in _.string.lower(_.str(2nd_smr))"> <b>2ndS <dtml-var 2nd_smr ><br></b><dtml-else> 2ndS <dtml-var 2nd_smr ><br></dtml-if> The above script won't save, and gives an error. The _.string.lower(_.str(2nd_smr)) expression is obviously the culprit and won't save unless I do ('2nd_smr') which saves but isn't what I want obviously, and ("2nd_smr") won't save. Did I screw up by naming a variable with a number as the first character? Is is salvageable with some funky syntax like: _.string.lower(_.str(_['{2nd_smr}'])) or do I have to just change the name of the variable? Thanks J
1. authenticated user is a user object not a string, use AUTHENTICATED_USER.getId() to get a string to compare against 2. use a python script 3. string in string doesn't work until python2.3, you'll have to do string in list/tuple. -kapil On Sat, 2004-03-27 at 22:58, Joshua Newman wrote:
Hi all,
I'm trying to compare an AUTHENTICATED_USER string to a variable which I named '2nd_smr' in this script to determine if it should be bolded in a big table and stick out for the user:
<dtml-if "_.string.lower(_.str( AUTHENTICATED_USER)) in _.string.lower(_.str(2nd_smr))"> <b>2ndS <dtml-var 2nd_smr ><br></b><dtml-else> 2ndS <dtml-var 2nd_smr ><br></dtml-if>
The above script won't save, and gives an error.
The _.string.lower(_.str(2nd_smr)) expression is obviously the culprit and won't save unless I do ('2nd_smr') which saves but isn't what I want obviously, and ("2nd_smr") won't save.
Did I screw up by naming a variable with a number as the first character?
Is is salvageable with some funky syntax like: _.string.lower(_.str(_['{2nd_smr}'])) or do I have to just change the name of the variable?
Thanks J
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Sun, 2004-03-28 at 03:55, Kapil Thangavelu wrote:
3. string in string doesn't work until python2.3, you'll have to do string in list/tuple.
doh forget that zope 2.7 works with 2.3, wohoo! ;-) also it if your not using that then it looks like you want string.index instead of 'string' in list cheers,
-kapil
participants (2)
-
Joshua Newman -
Kapil Thangavelu