[Zope-dev] Strings as input to the in tag: inconsistent
Martijn Pieters
mj@antraciet.nl
Wed, 26 May 1999 13:26:54 +0200
At 10:28 26/05/99 , Thilo Mezger wrote:
>hi!
>
>i've posted this problem on the zope-list a couple of days ago with no
>reply so i'm trying zope-dev now:
>
>i'm using this code to output A B C ... Z:
>
><!--#in "_.string.uppercase"-->
><!--#var sequence-item-->
><!--#/in-->
>
>this works fine in my Zope-1.10.2/Linux installation but Zope-1.10.2/Win95
>generates this error message:
>
>Error type: InError
>Error value: Strings are not allowed as input to the in tag.
>
>can someone explain this inconsistency? why are strings allowed on linux
>but not on win95?
Are you sure you are using the same version of python on both platforms?
You should get the same error on Linux as well, but it seems that
string.uppercase there returns a sequence of a type other than string.
On the Linux system, type 'python', then 'import string', and then
'string.uppercase' (all without the quotes).
It should print the string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' (with the quotes).
If it does, then somehow type checking is broken on your Linux python.
To check this, type: 'type(string.uppercase) is type("")'. It should print
1. If it doesn't, that's where your problem lies. If 0, look at
'type(string.uppercase)'. I do not know what it will say, but whatever it
is, it probably will be a bug.
Right now there is no easy way to convert _.string.uppercase into a
sequence of a type other than string, without resorting to external
methods. The next version of Zope will contain a _.range function, which is
similar to the default python range function. With that you could do:
<!--#in "_.range(_.len(_.string.uppercase))"-->
<!--#var "_.string.uppercase[_['sequence-item']]"-->
<!--#/in-->
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------