Re: [Zope] get property of type 'list'
Hi, Andrei I think I have it figured out. I just submitted something similar to the Collector about an analogous problem I have been having with 'lines' properties. When you create your tokens property, you should make its value a string, like: '1 2 3' not a list: [1, 2, 3] If your data is in a list and you want to use that list as tokens, you need to join the list into a string first: mylist = ['1', '2', '3'] fortokens = string.join(mylist,' ') That's the python, but you can do it in DTML using _.string.join(. Be careful to convert your integers to strings first. What's happening to you is that the string representation of the list, "[1, 2, 3]" is getting stored verbatim as your tokens property, and ZPublisher/Converters.py is then splitting it on the spaces when you ask for it. Which is how you get that weird '[1,' '2,' '3]'. -- Jim Washington Andrei Belitski wrote: Hi! I add a list property to a DTML document of type 'tokens' (e.g. '[1, 2, 3]') wenn i try to retrieve it with _.getitem i get '[1,' '2,' '3]' instead of '1' '2' '3' How can I get Zope to interpret my property like a list not a string or whatever else? Thank you in advance! ___ Zope maillist - [EMAIL PROTECTED] 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 ) -- Jim Washington Center for Assessment, Evaluation and Educational Programming Department of Teaching and Learning, Virginia Tech ___ Zope maillist - [EMAIL PROTECTED] 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 )
RE: [Zope] get property of type 'list'
From: Andrei Belitski [mailto:[EMAIL PROTECTED]] I add a list property to a DTML document of type 'tokens' (e.g. '[1, 2, 3]') wenn i try to retrieve it with _.getitem i get '[1,' '2,' '3]' instead of '1' '2' '3' How can I get Zope to interpret my property like a list not a string or whatever else? Actually it IS treating it as a list: dtml-var "tokens[0]" Should return '1' This should list each item: dtml-in tokens dtml-var sequence-itembr /dtml-in Regards Max M ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] get property of type 'list'
Andrei Belitski writes: I add a list property to a DTML document of type 'tokens' (e.g. '[1, 2, 3]') wenn i try to retrieve it with _.getitem i get '[1,' '2,' '3]' instead of '1' '2' '3' Are you sure, it was '[1,' '2,' '3]' and not ['1', '2', '3', '4']? If it were, it would be really strange, unbelievable. ['1', '2', '3', '4'] would be normal, when you use a list (it definitely is one!) in e.g.: dtml-var "_.getitem('toks')" as a list (of cause) can not be part of a generated HTML page. It must be converted into a string. And the above it the string representation of a list. To get the representation, you seem to favour (though I do not understand why), you could use: dtml-var "_.str(_.getitem('toks'))[1:-1]" This make the string conversion explicitly ("_.str") and then keeps the slice "[1:-1]" which means everything beside the first and last character, i.e. you chop the '[]'. Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )