Re: [Zope-dev] ZPT and 'else'
on 5/10/02 1:18 PM, Jeffrey P Shell at [EMAIL PROTECTED] scrivened: > > Still, yuck. It's - for better or worse - not a valid XML way. Even XSLT > does things like this: Well that makes this look palatable: > >>> You would at the very least need something like: >>> >>> ... >>> ... >>> ... >>> Still I think the concept of TAL having some kind of 'stack' for condition results makes sense and is worth exploring... Could yield better logical constructs, and things like case statements. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
On 5/10/02 9:25 AM, "Marc Lindahl" <[EMAIL PROTECTED]> wrote: > on 5/10/02 12:47 AM, Jeffrey P Shell at [EMAIL PROTECTED] scrivened: > >> >> You would need something to close off the 'if' statement, otherwise, a >> document full of 'if' statements and no 'else' ones could fill up a stack >> needlessly. > > What's so bad about that? The stack wouldn't carry over after > or - couldn't practically more than 1000's - insignificant! Still, yuck. It's - for better or worse - not a valid XML way. Even XSLT does things like this: http://www.w3.org/1999/XSL/Transform";> XSLT 1.1 required Sorry, this stylesheet requires XSLT 1.1. can stand on its own, but to do the equivalent of else, one has to use: (template) (template) (template) But, Page Templates are not XSLT. And I thank gods for that. XSLT is powerful, but I wouldn't be able to do the type of work I've been doing this week with them as easily as I've been able to do them with Page Templates. I couldn't even have done them as easily using DTML. >> You would at the very least need something like: >> >> ... >> ... >> ... >> >> >> Which would ensure / cut back on needless growth of stacks and/or global >> variables. >> >> Personally, I think the way Page Templates can do it (via a 'not' >> expression) is fine. When I used it today (and in the past), I never felt >> myself missing 'else', because there's not really an 'if' to begin with. >> Just conditions. It keeps TAL light, and lets TALES take on the lifting of >> how to write those conditions. > > Point is, it's slow and inefficient, and a clunky syntax. Reasons the whole > idea of 'else' was invented in the first place. I worry, that ZPT is > benchmarked 4x slower than DTML and it's becoming the standard - not a step > forward. And issue like this haven't been satisfactorily resolved. If speed mattered that much, we'd all still be using C and/or assembly language. "Scripting Languages" have become very standard, even though they're orders of magnitude slower than their compiled counterparts. I don't think it would be any more worth turning Page Templates back into an imperative programming language than it would be to turn Python into C. Or Haskell into Python. Or J into Lisp. Or Zope into PHP. Every language and platform has its strengths and weaknesses, and I think ZPT's strengths more than make up for its current speed deficiencies. I spend less time debugging and cleaning up Page Template code than I did with DTML, particularly late-generation DTML. And the results look *much* better. I personally can't see a way of having an else (or equivalent of 'xsl:choose') without starting to clutter up the current elegance of Page Templates, and it has to do with the way Page Templates are designed (and it's a design that I think is done pretty close to right). One reason being that, since all TAL things happen on attributes (it is the 'Template Attribute Language', and by law all XML attributes have to be quoted, you'd end up with something like this: Yay! Boo The only way out of this is to introduce special TAL tags. And at that point, we're back to some of the problems with DTML - 'special markup tags and the editors the bruise them'. And at _that_ point, we're out of one of the intended audiences of Page Templates. > I think, if it's going to have logic in there, make it sufficiently powerful > and efficient. Otherwise get rid of it altogether, unapologetically, and > require Python for such things Another option is the XMLC route, which is painful. XMLC identified every possible writable element with an id, and id only. Then, corresponding Java code could refer to that ID and replace the element with something. It kept the visual design side very clean, but the code to do the dynamic generation could get very ugly. Or, there's the option is to give up on templating altogether and go with PHP style syntax, or fill up Python code with: s += 'No contents available' I personally think Page Templates are rather elegant and a joy to use after five and a half years of DTML usage. I keep having to deal with other solutions like 'tea', 'cheetah', ASP/PSP, and it's just a mess. -- Jeffrey P Shell www.cuemedia.com ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
on 5/9/02 11:58 PM, Tim Hoffman at [EMAIL PROTECTED] scrivened: > The big problem with the whole 'else' issue as I see > it, is that non coders, using dreamweaver etc.. would no doubt end > up with both bit's of html in their template. > Don't you have that now with the kludgey 'not' construct? ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
on 5/10/02 12:47 AM, Jeffrey P Shell at [EMAIL PROTECTED] scrivened: > > You would need something to close off the 'if' statement, otherwise, a > document full of 'if' statements and no 'else' ones could fill up a stack > needlessly. What's so bad about that? The stack wouldn't carry over after or - couldn't practically more than 1000's - insignificant! > > You would at the very least need something like: > > ... > ... > ... > > > Which would ensure / cut back on needless growth of stacks and/or global > variables. > > Personally, I think the way Page Templates can do it (via a 'not' > expression) is fine. When I used it today (and in the past), I never felt > myself missing 'else', because there's not really an 'if' to begin with. > Just conditions. It keeps TAL light, and lets TALES take on the lifting of > how to write those conditions. Point is, it's slow and inefficient, and a clunky syntax. Reasons the whole idea of 'else' was invented in the first place. I worry, that ZPT is benchmarked 4x slower than DTML and it's becoming the standard - not a step forward. And issue like this haven't been satisfactorily resolved. I think, if it's going to have logic in there, make it sufficiently powerful and efficient. Otherwise get rid of it altogether, unapologetically, and require Python for such things ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
Tim Hoffman wrote: > > The big problem with the whole 'else' issue as I see > it, is that non coders, using dreamweaver etc.. would no doubt end > up with both bit's of html in their template. But that's exactly what you want! hey can then see what would happen in either case and will probabyl write better templates as a result :-) cheers, Chris ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
On 5/9/02 9:39 PM, "Marc Lindahl" <[EMAIL PROTECTED]> wrote: > Yecch! > > Why not: > > True stuff > > > False stuff > > > If leaves around boolean result, else picks up the most recent one... It's > like they push on a stack so you can nest them Something like that? You would need something to close off the 'if' statement, otherwise, a document full of 'if' statements and no 'else' ones could fill up a stack needlessly. You would at the very least need something like: ... ... ... Which would ensure / cut back on needless growth of stacks and/or global variables. Personally, I think the way Page Templates can do it (via a 'not' expression) is fine. When I used it today (and in the past), I never felt myself missing 'else', because there's not really an 'if' to begin with. Just conditions. It keeps TAL light, and lets TALES take on the lifting of how to write those conditions. -- Jeffrey P Shell www.cuemedia.com ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
The big problem with the whole 'else' issue as I see it, is that non coders, using dreamweaver etc.. would no doubt end up with both bit's of html in their template. T On Fri, 2002-05-10 at 11:39, Marc Lindahl wrote: > Yecch! > > Why not: > > True stuff > > > False stuff > > > If leaves around boolean result, else picks up the most recent one... It's > like they push on a stack so you can nest them Something like that? > > > on 5/9/02 11:10 PM, Jeffrey P Shell at [EMAIL PROTECTED] scrivened: > > > 'else' is tricky within the block oriented structure of anything XML-ish, > > because of the concept of 'well-formedness'. The 'if' statement would have > > to be singly wrapped, and the else block wrapped separately, looking at > > least somewhat awkward any way you go about it. The best I can come up with > > in my mind is this, in order to have the 'else' pick up on the condition > > expressed in its surrounding container. But, yuck: > > > > > > true stuff > > > > false stuff > > > > > > > > > > A good page template way is something like this: > > > > > > truth > > > > > > false > > > > > > The 'not' TALES namespace is valuable. The downside is that you evaluate > > the expression twice. A good way to work within this is something that I > > did earlier today, outside of this conversation, where I evaluate an > > expression earlier and assign it to a variable: > > > > >tal:define="editItems python:here.getMenuItem(...)"> > > > > Edit Menu Items > > > tal:condition="editItems"> > > > >... (form and table elements, and a loop over editItems > > contained in here if there were results) ... > > > > > > > > > tal:condition="not:editItems"> > > No menu items available > > > > > > > > > > > > This is something I did a lot in DTML too, setting a search result to either > > a global variable, or inside of a large namescape > > > > ___ > Zope-Dev maillist - [EMAIL PROTECTED] > http://lists.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > http://lists.zope.org/mailman/listinfo/zope-announce > http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPT and 'else'
Yecch! Why not: True stuff False stuff If leaves around boolean result, else picks up the most recent one... It's like they push on a stack so you can nest them Something like that? on 5/9/02 11:10 PM, Jeffrey P Shell at [EMAIL PROTECTED] scrivened: > 'else' is tricky within the block oriented structure of anything XML-ish, > because of the concept of 'well-formedness'. The 'if' statement would have > to be singly wrapped, and the else block wrapped separately, looking at > least somewhat awkward any way you go about it. The best I can come up with > in my mind is this, in order to have the 'else' pick up on the condition > expressed in its surrounding container. But, yuck: > > > true stuff > > false stuff > > > > > A good page template way is something like this: > > > truth > > > false > > > The 'not' TALES namespace is valuable. The downside is that you evaluate > the expression twice. A good way to work within this is something that I > did earlier today, outside of this conversation, where I evaluate an > expression earlier and assign it to a variable: > > tal:define="editItems python:here.getMenuItem(...)"> > > Edit Menu Items >tal:condition="editItems"> > >... (form and table elements, and a loop over editItems > contained in here if there were results) ... > > > > tal:condition="not:editItems"> > No menu items available > > > > > > This is something I did a lot in DTML too, setting a search result to either > a global variable, or inside of a large namescape ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] ZPT and 'else'
On 5/9/02 7:07 PM, "Tim Hoffman" <[EMAIL PROTECTED]> wrote: > Just my 2c worth, but I would like to defend order of execution of > ZPT. What it does mean for me is I can guaruntee zpt commands will > "always" be processed in a known order irrespective of where you > put them in a tag, this I like ;-) Me too. Occasional alarms, no surprises. > What I do miss is "else" clause but I think it would be probably > be too hard to implement, and too much of encouragement for people > to start putting more logic in the template, so on the whole it > is probably best to leave it out. > > See ya > > T > On Fri, 2002-05-10 at 05:15, Jim Penny wrote: >> My most-missed DTML feature has not been mentioned at all -- it is not >> loop batching -- it is the dtml-else option of dtml-in -- which made it >> much easier to handle the "nothing found" case. 'else' is tricky within the block oriented structure of anything XML-ish, because of the concept of 'well-formedness'. The 'if' statement would have to be singly wrapped, and the else block wrapped separately, looking at least somewhat awkward any way you go about it. The best I can come up with in my mind is this, in order to have the 'else' pick up on the condition expressed in its surrounding container. But, yuck: true stuff false stuff A good page template way is something like this: truth false The 'not' TALES namespace is valuable. The downside is that you evaluate the expression twice. A good way to work within this is something that I did earlier today, outside of this conversation, where I evaluate an expression earlier and assign it to a variable: Edit Menu Items ... (form and table elements, and a loop over editItems contained in here if there were results) ... No menu items available This is something I did a lot in DTML too, setting a search result to either a global variable, or inside of a large namescape -- Jeffrey P Shell www.cuemedia.com Industrie Toulouse on Zope http://radio.weblogs.com/0106123/categories/zope/ ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )