Im working with folders wich the ids are the years (2000, 1999 and so on). Im trying to list a folder using the following code: <dtml-with ZopeTime> <dtml-let ano="year()"> <dtml-in expr="ano.objectValues()"> <dtml-var id> </dtml-in> </dtml-let> </dtml-with> The year() function returns an Int, so when I call 'ano.objectValues()' zope does not understand it, because it is waiting a string. How can I turn my Int into a string? Or how can I make this easier? Thanks for the aid
How can I turn my Int into a string? Or how can I make this easier?
Don't know about the 'easier' bit, but to turn any other (primitive) data type into a string, you can enclose it in backwards single quotes. You know, this thing: ` Usually lives under the tilde (~) on standard US keyboards. It's really a Python thing you're asking. There's probably some function in the string library that does this too (I'm too lazy to look it up), if you think those silly quotes are inelegant. --jcc (its all in the quoting)
A couple of options: In dtml (yuck!) <dtml-in expr="_[_.str(ZopeTime().year())].objectValues()"> <dtml-var id> </dtml-in> In a python script: y = context.ZopeTime().year() for item in context[str(y)].objectValues(): print item.id() return printed Good luck! -- Jeffrey D. Peterson Webmaster/Web & Web Applications Engineer Range TV Cable & Broadband 1818 E. 3rd Ave. Hibbing, MN 55746 jpeterso@rangebroadband.com (And Steve Drees too...)
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Alexandre Aguiar Sent: Thursday, August 02, 2001 1:41 PM To: zope@zope.org Subject: [Zope] Int to String
Im working with folders wich the ids are the years (2000, 1999 and so on).
Im trying to list a folder using the following code:
<dtml-with ZopeTime> <dtml-let ano="year()"> <dtml-in expr="ano.objectValues()"> <dtml-var id> </dtml-in> </dtml-let> </dtml-with>
The year() function returns an Int, so when I call 'ano.objectValues()' zope does not understand it, because it is waiting a string.
How can I turn my Int into a string? Or how can I make this easier?
Thanks for the aid
_______________________________________________ Zope maillist - Zope@zope.org 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 )
participants (3)
-
Alexandre Aguiar -
J. Cameron Cooper -
Jeff Peterson