RE: [Zope] - Looping over the characters in a string in DTML...
Simon Michael writes:
Oh yes... I had a use for range() just the other day, and I meant to ask for it. Shall I add the request to Collector?
Good idea, please do. Perhaps we should ask for all (safe) python builtins to be exposed..
I would vote against this. DTML is AFAIK focused towards separation of scripting from HTML. If you need the reuslts of these function calls why not use an external method. This was more natural in BOBO (no need to manually add the method at some other/external point), but this is in the end the cleaner way. DTML functions should be there for easier formatting of HTML but not to build complex program logic into a HTML file. Just my humble opinion, __Janko Hauser
Janko Hauser wrote:
I would vote against this. DTML is AFAIK focused towards separation of scripting from HTML. If you need the reuslts of these function calls why not use an external method. This was more natural in BOBO (no need [...] DTML functions should be there for easier formatting of HTML but not to build complex program logic into a HTML file.
I don't see this at all -- DTML has tags like #in just so that complex program logic can be put into a document template. (At least, if you define a loop as "complex logic") Python is somewhat unusual among programming languages in not having a control contruct for a counting loop. BASIC, Pascal, FORTH, and PostScript have constructs for just that task. C and distantly related languages like Tcl and Perl have a more general "for" construct, but still clearly designed with counting loops in mind. They all provide these features because it's such a common task. The only reason Python gets away with not having that kind of construct is that it provides range() as a builtin. On a more practical note, producing a picklist of years given a start and end date seems like a fairly common thing to want do. Why should I have have to give a content author on my zope site access to the filesystem, just to write a one-line function wrapper around a builtin python function?
participants (2)
-
Janko Hauser -
Ty Sarna