From jim@digicool.com Sun Apr 1 16:35:07 2001 From: jim@digicool.com (Jim Fulton) Date: Sun, 01 Apr 2001 11:35:07 -0400 Subject: [ZPT] ZPT - tal-attributes in html-output ? References: <01c0b9b7$89f71900$376547c1@default> Message-ID: <3AC74AAB.8879F27E@digicool.com> Geir Bækholt wrote: > > Excuse my ignorance , i am , like almost everybody , new to the ZPT > , - but are the tal-attributes really supposed to be included in the > final HTML/XHTML-output of the rendered templates ? > > stuff like this : > TEST-TEMPLATE > is neat in the serverside source , but there is really no use for > the tal/tales/metal - syntax to be included in the rendered HTML as > far as i can see... > It doesn't look to good , and it could add a bit to the download.. > > opinions on this ?? I agree. tal/metal attributes shouldn't be included in the rendered output, although maybe there should be an option to include them, at least in the underlying software. (At one time, I dreamt that one could walk up to a rendered page and edit it. I've since given up on this for a number of reasons.) Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org From miles@jamkit.com Mon Apr 2 08:43:45 2001 From: miles@jamkit.com (Miles Waller) Date: Mon, 2 Apr 2001 08:43:45 +0100 Subject: [ZPT] ZPT Example Message-ID: Hi Evan, Any chance you could make your zclass/zpt application available as an example - it'd be really useful to see it all in action! Thanks, Miles Waller Jamkit Ltd. (T) +44 (0)20 7749 7218 (E) miles@jamkit.com (W) www.jamkit.com From Geir Bækholt Mon Apr 2 09:12:59 2001 From: Geir Bækholt (Geir Bækholt) Date: Mon, 2 Apr 2001 10:12:59 +0200 Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <3AC74AAB.8879F27E@digicool.com> References: <01c0b9b7$89f71900$376547c1@default> <3AC74AAB.8879F27E@digicool.com> Message-ID: <20520371634.20010402101259@funcom.com> Does this mean that we will see such an option (or the attributes removed) by 1.1 ?? they probably won't validate with w3c either (although this is a heavily discussed xml-namespace-issue at w3) :-) -- Geir Bækholt web-developer/designer geirh@funcom.com http://www.funcom.com on or about, Sunday, April 01, 2001, we have reason to believe that Jim Fulton wrote something in the lines of : JF> Geir Bækholt wrote: JF> I agree. tal/metal attributes shouldn't be included in the rendered output, JF> although maybe there should be an option to include them, at least in JF> the underlying software. JF> Jim Fulton From chrisw@nipltd.com Mon Apr 2 09:31:16 2001 From: chrisw@nipltd.com (Chris Withers) Date: Mon, 02 Apr 2001 09:31:16 +0100 Subject: [ZPT] TAL & ZPT 1.0.0 are up! References: <01d301c0b95c$3a818370$01000001@yosemite> Message-ID: <3AC838D4.DD99E00E@nipltd.com> Evan Simpson wrote: > > Subject says it all. There'll be a blurb in today's Zope News. Cool! :-) How do I/we/anyone go about creatign a filesystem and customisable version for the CMF? cheers, Chris From chrisw@nipltd.com Mon Apr 2 09:31:41 2001 From: chrisw@nipltd.com (Chris Withers) Date: Mon, 02 Apr 2001 09:31:41 +0100 Subject: [ZPT] ZPT Example References: Message-ID: <3AC838ED.B27424F3@nipltd.com> Miles Waller wrote: > > Any chance you could make your zclass/zpt application available as an > example - it'd be really useful to see it all in action! I'll second that :-) Chris From guido@digicool.com Mon Apr 2 14:20:52 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 02 Apr 2001 08:20:52 -0500 Subject: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: Your message of "Sun, 01 Apr 2001 11:35:07 -0400." <3AC74AAB.8879F27E@digicool.com> References: <01c0b9b7$89f71900$376547c1@default> <3AC74AAB.8879F27E@digicool.com> Message-ID: <200104021320.IAA02596@cj20424-a.reston1.va.home.com> > I agree. tal/metal attributes shouldn't be included in the rendered output, > although maybe there should be an option to include them, at least in > the underlying software. OK, I've added this to the TODO list. --Guido van Rossum (home page: http://www.python.org/~guido/) From guido@digicool.com Mon Apr 2 14:21:34 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 2 Apr 2001 09:21:34 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - README.txt:1.13 Message-ID: <20010402132134.ABD6351014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv28914 Modified Files: README.txt Log Message: Add new TODO entry. --- Updated File README.txt in package Packages/TAL -- --- README.txt 2001/03/30 18:31:25 1.12 +++ README.txt 2001/04/02 13:21:32 1.13 @@ -91,3 +91,5 @@ tal:replace and tal:attributes should not be required to do attribute replacement on the inserted text -- this would require a change to the TAL spec though. + +- In rendered HTML, the TAL attributes should be suppressed. From bitz@bitdance.com Mon Apr 2 14:48:41 2001 From: bitz@bitdance.com (R. David Murray ) Date: Mon, 2 Apr 2001 09:48:41 -0400 (EDT) Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <20520371634.20010402101259@funcom.com> Message-ID: On Mon, 2 Apr 2001, Geir B=E6kholt wrote: > Does this mean that we will see such an option (or the attributes > removed) by 1.1 ?? >=20 > they probably won't validate with w3c either (although this is a > heavily discussed xml-namespace-issue at w3) This sounds like a significant concern. My impression is that part of the whole point of TAL is that it *is* valid XML. Can you expand on what the argument is about, or set my mind at ease ? --RDM From bitz@bitdance.com Mon Apr 2 15:02:42 2001 From: bitz@bitdance.com (R. David Murray ) Date: Mon, 2 Apr 2001 10:02:42 -0400 (EDT) Subject: [ZPT] save changes linebreaks? In-Reply-To: <200103282223.RAA11161@cj20424-a.reston1.va.home.com> Message-ID: On Wed, 28 Mar 2001, Guido van Rossum wrote: > > joined onto the end of the previous line. I'm formatting it the > > way I want it to appear; is there some reason zpt can't save the > > formatting as I write it? > > The parsers don't pass on whitespace inside <...> constructs (nor a > few other details, like which type of quotes was used and whether you > wrote ">" or "<"). Well, that's certainly a good reason why it can't . > We were figuring that page templates are mostly useful for folks using > tools like DreamWeaver, who rarely view the HTML and don't care much > about how the HTML is formatted. One of the things that really bothers me, as a programmer, about DTML is the fact that it is impossible to format the combination of HTML and DTML in a logical, "pretty" fashion. I suspect you can sympathise with this frustration, Guido . So I'll probably switch to pagetemplates if for no other reason than to be able to rationally format my HTML/Zope source code. I can live with the formatting forced by the XML parser even though it produces ugly bits in long lines, given that leading whitespace on tags gets preserved correctly. > you). This is somewhat controversial; the reason why folks want this > is that expanding the macros in the template gives a more realistic > view of what it will look like -- again this is mostly for folks using > DreamWeaver. Yeah, it would actually be nice to have a switch that turned that feature on and off, since as a programmer working with vi it just gets in the way. But for working with coworkers who are HTML experts and not programmers, it looks to be a *very* nice feature. Unfortunately I won't be in a position to test that in practice for several months yet, since on my current project the HTML person does *not* use a WYSYWIG tool and so I'm just exposing to her the internal chunks of HTML. Using page templates/macro expansion in that context would, I think, just get in the way. --RDM From guido@digicool.com Mon Apr 2 16:12:51 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 02 Apr 2001 10:12:51 -0500 Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: Your message of "Mon, 02 Apr 2001 09:48:41 -0400." References: Message-ID: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> > > Does this mean that we will see such an option (or the attributes > > removed) by 1.1 ?? > > > > they probably won't validate with w3c either (although this is a > > heavily discussed xml-namespace-issue at w3) > > This sounds like a significant concern. My impression is that part of > the whole point of TAL is that it *is* valid XML. Can you expand on > what the argument is about, or set my mind at ease ? I'm no XML expert, but I've been told that it is well-formed XML, but won't validate because it's lacking a DTD. Apparently use of DTDs with XML is somewhat controversial, hence the "heavily discussed" comment. We should probably provide an option to suppress the TAL attributes in the rendered page. --Guido van Rossum (home page: http://www.python.org/~guido/) From mindlace@digicool.com Mon Apr 2 16:15:33 2001 From: mindlace@digicool.com (ethan mindlace fremen) Date: Mon, 02 Apr 2001 11:15:33 -0400 Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> Message-ID: <35110000.986224533@mindlace.digicool.com> --On Monday, April 02, 2001 10:12:51 -0500 Guido van Rossum wrote: >> > Does this mean that we will see such an option (or the attributes >> > removed) by 1.1 ?? >> > >> > they probably won't validate with w3c either (although this is a >> > heavily discussed xml-namespace-issue at w3) >> >> This sounds like a significant concern. My impression is that part of >> the whole point of TAL is that it *is* valid XML. Can you expand on >> what the argument is about, or set my mind at ease ? > > I'm no XML expert, but I've been told that it is well-formed XML, but > won't validate because it's lacking a DTD. Apparently use of DTDs > with XML is somewhat controversial, hence the "heavily discussed" > comment. We should probably provide an option to suppress the TAL > attributes in the rendered page. Well, AFAIK the real issue is that we mix namespaces, and although there is an example in the Namespaces spec of mixing namespaces (IIRC), there is no standard for doing so. this is why it isn't "valid" xml. It is my understanding that the XML Infoset standard will address this. -- ethan mindlace fremen zopatista community liason From fdrake@acm.org Mon Apr 2 16:57:01 2001 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Mon, 2 Apr 2001 11:57:01 -0400 (EDT) Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <35110000.986224533@mindlace.digicool.com> References: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> <35110000.986224533@mindlace.digicool.com> Message-ID: <15048.41293.819153.463736@cj42289-a.reston1.va.home.com> ethan mindlace fremen writes: > Well, AFAIK the real issue is that we mix namespaces, and although there is > an example in the Namespaces spec of mixing namespaces (IIRC), there is no > standard for doing so. this is why it isn't "valid" xml. Er, no. The issue is that validation simply isn't defined with namespaces in the general case. Validation is only defined for DTDs, so a DTD can be written that supports namespaces, but only by constraining the prefixes used for each namespace. This is all an artefact of namespaces being spliced on to XML after the XML 1.0 recommendation. There appears to have been little interest in the original namespaces group regarding validation; the real target was the "well-formed is fine with me" usage of XML. > It is my understanding that the XML Infoset standard will address this. I don't know if this is the case; they might deal with validation and namespaces. I suspect that XSchema validation supports this. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From fdrake@acm.org Mon Apr 2 17:05:09 2001 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Mon, 2 Apr 2001 12:05:09 -0400 (EDT) Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> References: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> Message-ID: <15048.41781.336827.972263@cj42289-a.reston1.va.home.com> Guido van Rossum writes: > I'm no XML expert, but I've been told that it is well-formed XML, but > won't validate because it's lacking a DTD. Apparently use of DTDs If you use the DOCTYPE declaration with either (or both) an internal or external subset, it has a DTD. It won't validate to the HTML DTD if you actually use any METAL/TAL attributes, the input document won't validate because it's *not* valid HTML. The output won't validate unless we rip the METAL/TAL attributes from the output (and then, only if the result is otherwise valid). > with XML is somewhat controversial, hence the "heavily discussed" No; what's controversial is what validation might mean in the presence of namespaces; see my previous message for more information. > comment. We should probably provide an option to suppress the TAL > attributes in the rendered page. We should provide that option anyway. Some people will want to hide the implementation details of their site as a matter of policy. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From chrisw@nipltd.com Mon Apr 2 17:38:35 2001 From: chrisw@nipltd.com (Chris Withers) Date: Mon, 02 Apr 2001 17:38:35 +0100 Subject: [ZPT] ZPT - tal-attributes in html-output ? References: <200104021512.KAA03124@cj20424-a.reston1.va.home.com> <15048.41781.336827.972263@cj42289-a.reston1.va.home.com> Message-ID: <3AC8AB0B.A9DDAE25@nipltd.com> "Fred L. Drake, Jr." wrote: > We should provide that option anyway. Some people will want to hide > the implementation details of their site as a matter of policy. Yes please :-) Chris From jim@digicool.com Mon Apr 2 18:36:32 2001 From: jim@digicool.com (Jim Fulton) Date: Mon, 02 Apr 2001 13:36:32 -0400 Subject: [ZPT] ZPT - tal-attributes in html-output ? References: Message-ID: <3AC8B8A0.4BF804BF@digicool.com> "R. David Murray" wrote: > > On Mon, 2 Apr 2001, Geir Bækholt wrote: > > Does this mean that we will see such an option (or the attributes > > removed) by 1.1 ?? > > > > they probably won't validate with w3c either (although this is a > > heavily discussed xml-namespace-issue at w3) > > This sounds like a significant concern. My impression is that part of > the whole point of TAL is that it *is* valid XML. The term "valid" in XML (and SGML) has a meaning that is more specific than you may realize. The term "valid" means that a document conforms to a DTD. TAL cannot be "valid" in this sense, because it doesn't conform to a specific DTD. It happens that xml namespaces and DTDs are currently (at least the last time I checked ;) incompatable. Page templates *are* well formed, which is all most editors care about. Further, the output is well formed. There is *some* (though for most practical purposes, not much) value in ommiting tal/metal attributes from page-template output, so that the attributes don't cause otherwise valid output to be invalid. That is why we've decided to change this behavior in 1.1. > Can you expand on > what the argument is about, or set my mind at ease ? If the description above doesn't help, then, if you can, just trust me and relax. ;) Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org From fdrake@acm.org Mon Apr 2 18:52:19 2001 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Mon, 2 Apr 2001 13:52:19 -0400 (EDT) Subject: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <3AC8B8A0.4BF804BF@digicool.com> References: <3AC8B8A0.4BF804BF@digicool.com> Message-ID: <15048.48211.29775.369025@cj42289-a.reston1.va.home.com> Jim Fulton writes: > The term "valid" in XML (and SGML) has a meaning that is more > specific than you may realize. The term "valid" means that a > document conforms to a DTD. TAL cannot be "valid" in this sense, > because it doesn't conform to a specific DTD. It happens that > xml namespaces and DTDs are currently (at least the last time I checked ;) > incompatable. Well, that's not exactly it either. We could easily write *a* DTD for it, if we're willing to restrict the prefixes. But that wouldn't be the same as letting the users pick an *arbitrary* DTD and make the results conform to that -- we'd have to pick some W3C HTML DTD. Well, we could get fancier and have modified versions of all of them, and re-write the DOCTYPE declaration on the way out (actually a relatively reasonable way to do this), but I suspect some of the authoring tools would have difficulty understanding the use of different doctypes for editing. This is one of those cases where well-formed XML is the right thing, and monkeying around with validation for intermediate forms is just distraction. Adding an option to remove the METAL/TAL attributes from the output allows the result of transformation to be valid, and I suspect that's what people really care about. > Page templates *are* well formed, which is all most editors care > about. Further, the output is well formed. And *that's* what's really important! -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From miles@jamkit.com Mon Apr 2 22:04:12 2001 From: miles@jamkit.com (Miles Waller) Date: Mon, 2 Apr 2001 22:04:12 +0100 Subject: [ZPT] ZPT - tal-attributes in html-output ? Message-ID: I hope I'm not being stupid here, but aren't the TAL/METAL attributes required so that when a designer requests a page to edit, say using webdav, they get a marked-up page so that when they upload it again, all the TAL/METAL information isn't overwritten? Let me know where I'm going wrong! miles [] j a m k i t miles waller T: 020 7749 7218 F: 020 7739 8683 M: 07968 301 337 W: www.jamkit.com From evan@digicool.com Mon Apr 2 22:39:34 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 2 Apr 2001 16:39:34 -0500 Subject: [ZPT] ZPT - tal-attributes in html-output ? References: Message-ID: <028801c0bbbd$69076800$2a01a8c0@evansys> From: "Miles Waller" > I hope I'm not being stupid here, but aren't the TAL/METAL attributes > required so that when a designer requests a page to edit, say using webdav, > they get a marked-up page so that when they upload it again, all the > TAL/METAL information isn't overwritten? When you ask for the page source, yes; Not when it is rendered. It is important to remember this distinction, especially when setting up a WebDAV connection. You must be sure to set up a source port with z2.py (-W 8081, for instance) and use that for all of your WebDAV work. Cheers, Evan @ digicool From richard@bizarsoftware.com.au Wed Apr 4 01:58:24 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Wed, 04 Apr 2001 10:58:24 +1000 Subject: [ZPT] My First Post Message-ID: <3ACA71B0.517CA450@bizarsoftware.com.au> Hi all, ZPT rocks. Had to get that out in the open :) These comments come after one end-to-end read of the TALES, TAL and METAL 1.0 specification pages. My apologies in advance if I'm offending anyone who has spent far too much time (possibly in far too many meetings) already working through this stuff. TAL statements: define, attributes, condition, content, replace, repeat - why is attributes plural? It may be used to define a single attribute replacement. Similarly, define may be used for either a single or multiple definition. So as far as I'm concerned, attributes should just be attribute. Or define should be definitions. One or the other. Or is it just Too Late to be bringing this stuff up? In my reading, I found a couple of "bonus" attribute names used in the documentation. In the TAL spec under Define, there's an example: tal:define="mytitle template/title; tlen python:len(local.mytitle)" I presume that TAL has created the "builtin" attribute in the TALES namespace called 'local'? Is there a 'global'? Is there anything else? I know there's a 'repeat' for the repeat statement. If 'global' doesn't exist as an attribute, should it? Similarly, METAL creates a 'macros' attribute (again, this is plural when we have 'local'). I don't believe METAL creates any other attributes. The attribute is mentioned almost as an aside in the documentation. I guess it'd just be nice to have these new attributes explicitly listed somewhere like they are in the TALES spec. I just don't want to get into the situation we have with DTML where there's inconsistencies and documentation that, for a very long time, ignored or "obscured" some very useful features. Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From evan@digicool.com Wed Apr 4 05:01:15 2001 From: evan@digicool.com (Evan Simpson) Date: Tue, 3 Apr 2001 23:01:15 -0500 Subject: [ZPT] My First Post References: <3ACA71B0.517CA450@bizarsoftware.com.au> Message-ID: <057501c0bcbb$e5802260$2a01a8c0@evansys> From: > ZPT rocks. Had to get that out in the open :) Thanks! Glad you like it. > Too Late to be bringing this stuff up? Probably. Now that we have a 1.0 release, we're not likely to tweak the spelling unless there's a great outcry. > tal:define="mytitle template/title; tlen python:len(local.mytitle)" This is a remnant from earlier experiments. At one point, there were 'global', 'local', and 'var' (combined) variables. Now there's just 'repeat'. The example above should really look like this: tal:define="mytitle template/title; tlen python:len(mytitle)" > Similarly, METAL creates a 'macros' attribute (again, this is plural when > we have 'local'). I don't believe METAL creates any other attributes. The > attribute is mentioned almost as an aside in the documentation. Actually, this is an implementation detail of ZPT, not a feature of METAL. METAL doesn't really care how macros are exposed and accessed. Cheers, Evan @ digicool From Geir Bækholt Wed Apr 4 11:43:25 2001 From: Geir Bækholt (Geir Bækholt) Date: Wed, 4 Apr 2001 12:43:25 +0200 Subject: Re[2]: [ZPT] ZPT - tal-attributes in html-output ? In-Reply-To: <028801c0bbbd$69076800$2a01a8c0@evansys> References: <028801c0bbbd$69076800$2a01a8c0@evansys> Message-ID: <6913674703.20010404124325@funcom.com> this seems to work nicely .. Any info on how to set those parameters when running as a service on win2k ?? -- Geir Bækholt web-developer/designer geirh@funcom.com http://www.funcom.com on or about, Monday, April 02, 2001, we have reason to believe that Evan Simpson wrote something along the lines of : ES> When you ask for the page source, yes; Not when it is rendered. ES> It is important to remember this distinction, especially when setting up a ES> WebDAV connection. You must be sure to set up a source port with z2.py (-W ES> 8081, for instance) and use that for all of your WebDAV work. ES> Cheers, ES> Evan @ digicool From Geir Bækholt Wed Apr 4 13:12:13 2001 From: Geir Bækholt (Geir Bækholt) Date: Wed, 4 Apr 2001 14:12:13 +0200 Subject: [ZPT] doctypes are left out ? Message-ID: <10219002664.20010404141213@funcom.com> As tal / metal statements are tied to xml/html-elements , there seems to be no way to pull doctype declarations from templates/macros.. (doctypes are as we all know declared before the element, which seems to be the first one available to use for metal-macro-definitions.. ) Is there some way that i just didn't discover , or is it an inherent lack in the system ? -- Geir Bækholt web-developer/designer geirh@funcom.com http://www.funcom.com From Geir Bækholt Wed Apr 4 13:56:50 2001 From: Geir Bækholt (Geir Bækholt) Date: Wed, 4 Apr 2001 14:56:50 +0200 Subject: [ZPT] nesting macros Message-ID: <7721680114.20010404145650@funcom.com> it seems to be intended to be able to nest metal-macros , but this seems a bit problematic when the nested macros contain slots.. i have a (somewhat simplified) structure like this : macrotemplate1 (defines a bit of html with 3 slots metal:define-macro="itemWithSlots" macrotemplate2 (defines a common look and feel , including itemWithSlots : metal:use-macro="here/macrotemplate1/macros/itemWithSlots when i try to use the common look and feel macro from macrotemplate2 , the itemWithSlots macro won't take my values for fill-slot. - it always renders whatever is defined in macrotemplate2 , whether i use fill-slot or define-slot there.. have anybody looked at constructs like this ? -- Geir Bækholt web-developer/designer geirh@funcom.com http://www.funcom.com From shane@digicool.com Wed Apr 4 22:49:35 2001 From: shane@digicool.com (Shane Hathaway) Date: Wed, 04 Apr 2001 17:49:35 -0400 Subject: [ZPT] Patches to PageTemplate product Message-ID: <3ACB96EF.56EE374C@digicool.com> I used ZPT for the first time today. I jumped right in. It works well for the most part, but I really had trouble until I applied the following patches. Should I check them in? Expressions.py is not good about invoking DTML. The patch fixes it. It also invokes the security machinery correctly in restrictedTraverse(). PageTemplate.py and TALES.py generated exceptions that were very difficult to interpret until I patched them. Also, we really need to look into providing a way to zero in on a runtime error in a template, similar to what ZDebug does (it shows the source of the DTML with the problematic statement highlighted in red.) Shane Index: Expressions.py =================================================================== RCS file: /cvs-repository/Packages/Products/PageTemplates/Expressions.py,v retrieving revision 1.4 diff -u -r1.4 Expressions.py --- Expressions.py 2001/03/27 15:10:09 1.4 +++ Expressions.py 2001/04/04 21:44:40 @@ -95,6 +95,7 @@ from TALES import Engine, CompilerError, _valid_name, NAME_RE from string import strip, split, join, replace, lstrip from DocumentTemplate.DT_Util import TemplateDict +from Acquisition import aq_base, aq_parent _engine = None def getEngine(): @@ -114,6 +115,24 @@ reg('not', NotExpr) reg('import', ImportExpr) +def render(ob): + """ + Calls the object, possibly a document template, or just returns it if + not callable. + """ + base = aq_base(ob) + if callable(base): + try: + if getattr(base, 'isDocTemp', 0): + ob = ob(ob, ob.REQUEST) + else: + ob = ob() + except AttributeError, n: + if n != '__call__': + raise + return ob + + class PathExpr: def __init__(self, name, expr): self._s = expr @@ -158,10 +177,11 @@ return 1 if self._name == 'nocall': return ob - mm = TemplateDict() - mm._push(var) - mm._push({'_ob': ob}) - return mm['_ob'] + return render(ob) +## mm = TemplateDict() +## mm._push(var) +## mm._push({'_ob': ob}) +## return mm['_ob'] def __str__(self): return '%s expression "%s"' % (self._name, self._s) @@ -310,6 +330,8 @@ if not path: return self + __traceback_info__ = path + get=getattr N=None M=[] #marker @@ -335,7 +357,7 @@ raise 'NotFound', name if name=='..': - o=getattr(object, 'aq_parent', M) + o = aq_parent(object) if o is not M: if not securityManager.validate(object, object, name, o): raise 'Unauthorized', name @@ -354,19 +376,13 @@ else: o=get(object, name, M) if o is not M: - # waaaa - if hasattr(get(object,'aq_base',object), name): - # value wasn't acquired - if not securityManager.validate( - object, object, name, o): - raise 'Unauthorized', name - pass + # Check security. + if hasattr(object, 'aq_acquire'): + object.aq_acquire( + name, validate2, securityManager.validate) else: - if not securityManager.validate( - object, None, name, o): + if not securityManager.validate(object, object, name, o): raise 'Unauthorized', name - pass - else: o=object[name] if not securityManager.validate(object, object, None, o): @@ -374,3 +390,9 @@ object = o return object + + +def validate2(orig, inst, name, v, real_validate): + if not real_validate(orig, inst, name, v): + raise 'Unauthorized', name + return 1 Index: PageTemplate.py =================================================================== RCS file: /cvs-repository/Packages/Products/PageTemplates/PageTemplate.py,v retrieving revision 1.4 diff -u -r1.4 PageTemplate.py --- PageTemplate.py 2001/03/29 10:21:56 1.4 +++ PageTemplate.py 2001/04/04 21:44:40 @@ -145,7 +145,7 @@ output = StringIO() c = self.pt_getContext() c.update(extra_context) - __traceback_info__ = c + #__traceback_info__ = c TALInterpreter(self._v_program, self._v_macros, getEngine().getContext(c), Index: TALES.py =================================================================== RCS file: /cvs-repository/Packages/Products/PageTemplates/TALES.py,v retrieving revision 1.3 diff -u -r1.3 TALES.py --- TALES.py 2001/03/29 10:22:33 1.3 +++ TALES.py 2001/04/04 21:44:40 @@ -252,10 +252,10 @@ def evaluate(self, expression): if type(expression) is type(''): expression = self._engine.compile(expression) - try: - return expression(self) - except: - raise TALESError, (`expression`, sys.exc_info()) + #try: + return expression(self) + #except: + # raise TALESError, (`expression`, sys.exc_info()) evaluateValue = evaluate From richard@bizarsoftware.com.au Thu Apr 5 01:25:08 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Thu, 05 Apr 2001 10:25:08 +1000 Subject: [ZPT] My PageTemplateFile first cut Message-ID: <3ACBBB64.B2A44AC3@bizarsoftware.com.au> This is a multi-part message in MIME format. --------------BF1CF372069378FB2933B0D6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Here's a first cut at a PageTemplateFile class. This is intended to integrate seamlessly into our existing Product, which it does pretty well. In order to have that seamless integration, I had to modify the __call__ signature and handling so it reflected (HTML|DTML)File. What's the call here? If the REQUEST object is put into extra_content as the 'options' tuple - as is the case with the PageTemplate.__call__ method - it doesn't seem to be assigned to the 'request' attribute. There's no code in PageTemplate or TALES to do it that I can see... Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) --------------BF1CF372069378FB2933B0D6 Content-Type: application/octet-stream; name="PageTemplateFile.py" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="PageTemplateFile.py" aW1wb3J0IG9zCmltcG9ydCBHbG9iYWxzCmZyb20gQWNxdWlzaXRpb24gaW1wb3J0IEltcGxp Y2l0CmZyb20gUGVyc2lzdGVuY2UgaW1wb3J0IFBlcnNpc3RlbnQKZnJvbSBQcm9kdWN0cy5Q YWdlVGVtcGxhdGVzLlBhZ2VUZW1wbGF0ZSBpbXBvcnQgUGFnZVRlbXBsYXRlCgpjbGFzcyBQ YWdlVGVtcGxhdGVGaWxlKFBhZ2VUZW1wbGF0ZSwgSW1wbGljaXQsIFBlcnNpc3RlbnQpOgog ICAgJycnIHdvb3QsIHBhZ2UgdGVtcGxhdGVzCiAgICAnJycKICAgIF92X2xhc3RfcmVhZD0w CgogICAgZGVmIF9faW5pdF9fKHNlbGYsIGZpbGVuYW1lKToKICAgICAgICBzZWxmLmZpbGVu YW1lID0gZmlsZW5hbWUKICAgICAgICBzZWxmLnB0X2VkaXQob3BlbihmaWxlbmFtZSksICd0 ZXh0L2h0bWwnKQogICAgICAgIHNlbGYuX3ZfbGFzdF9yZWFkID0gb3Muc3RhdChmaWxlbmFt ZSlbOF0KCiAgICBkZWYgX2Nvb2tfY2hlY2soc2VsZik6CiAgICAgICAgbXRpbWUgPSBvcy5z dGF0KHNlbGYuZmlsZW5hbWUpWzhdCiAgICAgICAgaWYgbXRpbWUgIT0gc2VsZi5fdl9sYXN0 X3JlYWQ6CiAgICAgICAgICAgIHNlbGYucHRfZWRpdChvcGVuKHNlbGYuZmlsZW5hbWUpLCAn dGV4dC9odG1sJykKICAgICAgICAgICAgc2VsZi5fdl9sYXN0X3JlYWQgPSBtdGltZQoKICAg IGRlZiBfX2NhbGxfXyhzZWxmLCBvYmosIFJFUVVFU1QsICoqa3dhcmdzKToKICAgICAgICAn Jycgd29vdCwgcGFnZSB0ZW1wbGF0ZXMKICAgICAgICAnJycKICAgICAgICBzZWxmLl9jb29r KCkKICAgICAgICBpZiBHbG9iYWxzLkRldmVsb3BtZW50TW9kZToKICAgICAgICAgICAgc2Vs Zi5fY29va19jaGVjaygpCiAgICAgICAgaWYgbm90IGt3YXJncy5oYXNfa2V5KCdhcmdzJyk6 CiAgICAgICAgICAgIGt3YXJnc1snYXJncyddID0gKG9iaiwgKQogICAgICAgIHJldHVybiBz ZWxmLnB0X3JlbmRlcihleHRyYV9jb250ZXh0PXsnb3B0aW9ucyc6IGt3YXJncywKICAgICAg ICAgICAgJ3JlcXVlc3QnOiBSRVFVRVNUfSkKCg== --------------BF1CF372069378FB2933B0D6-- From richard@bizarsoftware.com.au Thu Apr 5 03:10:06 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Thu, 05 Apr 2001 12:10:06 +1000 Subject: [ZPT] repeat attribute? Message-ID: <3ACBD3FE.963FF30D@bizarsoftware.com.au> The following PT fragment breaks, unable to find 'repeat':
1: txt
I've poked around the TAL source and I can't find where the attribute is generated... Still looking... Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Thu Apr 5 03:15:30 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Thu, 05 Apr 2001 12:15:30 +1000 Subject: [ZPT] repeat attribute? References: <3ACBD3FE.963FF30D@bizarsoftware.com.au> Message-ID: <3ACBD542.3AF0278F@bizarsoftware.com.au> richard@bizarsoftware.com.au wrote: > > The following PT fragment breaks, unable to find 'repeat': > >
> 1: > txt
>
> > I've poked around the TAL source and I can't find where the attribute is > generated... > > Still looking... OK, I found where the attribute is created, and it's called 'loop', in TALES.Context.setRepeat... So, which is wrong, the 1.0 spec or the code? Now, when I switch to using 1, I get a security assertion error: Unauthorized: Access denied for because its container, , has no security assertions. ... erk... Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From evan@digicool.com Thu Apr 5 03:28:18 2001 From: evan@digicool.com (Evan Simpson) Date: Wed, 4 Apr 2001 21:28:18 -0500 Subject: [ZPT] repeat attribute? References: <3ACBD3FE.963FF30D@bizarsoftware.com.au> <3ACBD542.3AF0278F@bizarsoftware.com.au> Message-ID: <017601c0bd78$1ae98290$2a01a8c0@evansys> From: > OK, I found where the attribute is created, and it's called 'loop', in > TALES.Context.setRepeat... > > So, which is wrong, the 1.0 spec or the code? The code. I ran into that problem, and the lack of security assertions, this morning. I'll have the fixes in CVS this evening. Cheers, Evan @ digicool From evan@digicool.com Thu Apr 5 04:22:53 2001 From: evan@digicool.com (Evan Simpson) Date: Wed, 4 Apr 2001 22:22:53 -0500 Subject: [ZPT] Extending tal:condition, making metal:define Message-ID: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> Here's two ideas I had while using ZPT today: 1. Suppose that I want to replace a tag, but only if the replacement value exists, otherwise I want to keep the dummy text. Right now, this is the best I can do: The Text Ditto for 'content' and 'attributes'. This isn't that bad, but I thought about extending 'condition', so that you could write: The Text Grammar-wise: ([replace|content|attributes] expression)+ 2. Some of the METAL paths I've been using get pretty long, and if I wanted to use several macros from the same template it would be great to be able to 'metal:define'. This could work the same way as 'tal:define', except at METAL time. Could be confusing, though. Cheers, Evan @ digicool From richard@bizarsoftware.com.au Thu Apr 5 04:54:58 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Thu, 05 Apr 2001 13:54:58 +1000 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> Message-ID: <3ACBEC92.9E01F759@bizarsoftware.com.au> Evan Simpson wrote: > > Here's two ideas I had while using ZPT today: > > 1. Suppose that I want to replace a tag, but only if the replacement > value exists, otherwise I want to keep the dummy text. Right now, this > is the best I can do: > > tal:replace="request/foo"> > The Text > > Ditto for 'content' and 'attributes'. This isn't that bad, but I > thought about extending 'condition', so that you could write: > > tal:replace="request/foo">The Text Another approach would be to have the condition be able to break out of the processing for that tag if it fails, and not remove the tag. Something like: The Text Or maybe a whole new TAL statement is required? The Text or The Text Perhaps what we really want is a way for replace to fail gracefully? The Text My favourite is a tie between the last two... They're probably easier to actually implement, and it's much more obvious what they're doing. Not that we'd have to go with 'only_if_exists' as the actual keyword ;) Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Thu Apr 5 05:26:27 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Thu, 05 Apr 2001 14:26:27 +1000 Subject: [ZPT] My PageTemplateFile first cut References: <3ACBBB64.B2A44AC3@bizarsoftware.com.au> Message-ID: <3ACBF3F3.5474A515@bizarsoftware.com.au> This is a multi-part message in MIME format. --------------D5B3B1621DDE6AFCBB5FF1C7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit richard@bizarsoftware.com.au wrote: > Here's a first cut at a PageTemplateFile class. This is intended to > integrate seamlessly into our existing Product, which it does pretty well. > In order to have that seamless integration, I had to modify the __call__ > signature and handling so it reflected (HTML|DTML)File. What's the call > here? If the REQUEST object is put into extra_content as the 'options' > tuple - as is the case with the PageTemplate.__call__ method - it doesn't > seem to be assigned to the 'request' attribute. There's no code in > PageTemplate or TALES to do it that I can see... I've made a change so that the template is rendered on the correct object (the 'here' object is now the same as the 'client' argument in DT_String terminology). Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) --------------D5B3B1621DDE6AFCBB5FF1C7 Content-Type: application/octet-stream; name="PageTemplateFile.py" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="PageTemplateFile.py" aW1wb3J0IG9zCmltcG9ydCBHbG9iYWxzCmZyb20gQWNxdWlzaXRpb24gaW1wb3J0IEltcGxp Y2l0CmZyb20gUGVyc2lzdGVuY2UgaW1wb3J0IFBlcnNpc3RlbnQKZnJvbSBQcm9kdWN0cy5Q YWdlVGVtcGxhdGVzLlBhZ2VUZW1wbGF0ZSBpbXBvcnQgUGFnZVRlbXBsYXRlCgpjbGFzcyBQ YWdlVGVtcGxhdGVGaWxlKFBhZ2VUZW1wbGF0ZSwgSW1wbGljaXQsIFBlcnNpc3RlbnQpOgog ICAgJycnIHdvb3QsIHBhZ2UgdGVtcGxhdGVzCiAgICAnJycKICAgIF92X2xhc3RfcmVhZD0w CgogICAgZGVmIF9faW5pdF9fKHNlbGYsIGZpbGVuYW1lKToKICAgICAgICBzZWxmLmZpbGVu YW1lID0gZmlsZW5hbWUKICAgICAgICBzZWxmLnB0X2VkaXQob3BlbihmaWxlbmFtZSksICd0 ZXh0L2h0bWwnKQogICAgICAgIHNlbGYuX3ZfbGFzdF9yZWFkID0gb3Muc3RhdChmaWxlbmFt ZSlbOF0KCiAgICBkZWYgX2Nvb2tfY2hlY2soc2VsZik6CiAgICAgICAgbXRpbWUgPSBvcy5z dGF0KHNlbGYuZmlsZW5hbWUpWzhdCiAgICAgICAgaWYgbXRpbWUgIT0gc2VsZi5fdl9sYXN0 X3JlYWQ6CiAgICAgICAgICAgIHNlbGYucHRfZWRpdChvcGVuKHNlbGYuZmlsZW5hbWUpLCAn dGV4dC9odG1sJykKICAgICAgICAgICAgc2VsZi5fdl9sYXN0X3JlYWQgPSBtdGltZQoKICAg IGRlZiBfX2NhbGxfXyhzZWxmLCBvYmosIFJFUVVFU1QsICoqa3dhcmdzKToKICAgICAgICAn Jycgd29vdCwgcGFnZSB0ZW1wbGF0ZXMKICAgICAgICAnJycKICAgICAgICBzZWxmLl9jb29r KCkKICAgICAgICBpZiBHbG9iYWxzLkRldmVsb3BtZW50TW9kZToKICAgICAgICAgICAgc2Vs Zi5fY29va19jaGVjaygpCiAgICAgICAgdGVtcGxhdGUgPSBzZWxmLl9fb2ZfXyhvYmopCiAg ICAgICAgcmV0dXJuIHRlbXBsYXRlLnB0X3JlbmRlcihleHRyYV9jb250ZXh0PXsnb3B0aW9u cyc6IGt3YXJncywKICAgICAgICAgICAgJ3JlcXVlc3QnOiBSRVFVRVNUfSkKCg== --------------D5B3B1621DDE6AFCBB5FF1C7-- From shane@digicool.com Thu Apr 5 14:50:52 2001 From: shane@digicool.com (Shane Hathaway) Date: Thu, 05 Apr 2001 09:50:52 -0400 Subject: [ZPT] My First Post References: <3ACA71B0.517CA450@bizarsoftware.com.au> <057501c0bcbb$e5802260$2a01a8c0@evansys> Message-ID: <3ACC783C.D64DB1B2@digicool.com> Evan Simpson wrote: > > From: > > Similarly, METAL creates a 'macros' attribute (again, this is plural > when > > we have 'local'). I don't believe METAL creates any other attributes. > The > > attribute is mentioned almost as an aside in the documentation. > > Actually, this is an implementation detail of ZPT, not a feature of > METAL. METAL doesn't really care how macros are exposed and accessed. FYI if you forget the "macros" keyword or forget to include the name of the macro to use (what can happen if the whole page template is supposed to be a macro), ZPT fails in ugly ways. This particular error handling needs improvement. Shane From fdrake@acm.org Thu Apr 5 18:11:34 2001 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Thu, 5 Apr 2001 13:11:34 -0400 (EDT) Subject: [Geeks] Re: [ZPT] repeat attribute? In-Reply-To: <004c01c0bdec$53542990$2a04000a@evansys> References: <004c01c0bdec$53542990$2a04000a@evansys> Message-ID: <15052.42822.578477.952022@cj42289-a.reston1.va.home.com> Evan Simpson writes: > Yes, Packages/TAL and Products/DC/PageTemplates, please. > PresentationTemplates is stale, don't bother with it. These should be getting exported to the public CVS whenever that gets synced. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From hamish_lawson@yahoo.co.uk Thu Apr 5 21:06:20 2001 From: hamish_lawson@yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Thu, 5 Apr 2001 21:06:20 +0100 (BST) Subject: [ZPT] Authoring tools and tag-nesting problems Message-ID: <20010405200620.15424.qmail@web214.mail.yahoo.com> I've encountered a problem with using authoring tools to style ZPT documents. I had a template with the following snippet: Joe When I edited this template in Dreamweaver UltraDev and applied a subtle shade of pink to "Joe", I found that the resulting HTML was: Joe That is, Dreamweaver applied the tag just to "Joe" and not around the bold tags enclosing the text (other authoring tools may well do the same, and I'm not sure we could say wrongly). This means that when the template is rendered, the tag ends up being lost when it (and not just "Joe") gets replaced by the value of "container/name". Other than subsequently tweaking the HTML code manually (but doesn't that defeat one of the goals of ZPT?), how can we be sure that the TAL statements will be on the appropriate (i.e. innermost) tag after compound styling has been applied? Or is there a way to have a "tal:content" statement affect only the innermost content? And if not, ought there to be? Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From guido@digicool.com Thu Apr 5 22:55:14 2001 From: guido@digicool.com (Guido van Rossum) Date: Thu, 05 Apr 2001 16:55:14 -0500 Subject: [ZPT] Authoring tools and tag-nesting problems In-Reply-To: Your message of "Thu, 05 Apr 2001 21:06:20 +0100." <20010405200620.15424.qmail@web214.mail.yahoo.com> References: <20010405200620.15424.qmail@web214.mail.yahoo.com> Message-ID: <200104052155.QAA11260@cj20424-a.reston1.va.home.com> > I've encountered a problem with using authoring tools to style ZPT > documents. > > I had a template with the following snippet: > > Joe > > When I edited this template in Dreamweaver UltraDev and applied a > subtle shade of pink to "Joe", I found that the resulting HTML was: > > Joe > > That is, Dreamweaver applied the tag just to "Joe" and not > around the bold tags enclosing the text (other authoring tools may well > do the same, and I'm not sure we could say wrongly). This means that > when the template is rendered, the tag ends up being lost when > it (and not just "Joe") gets replaced by the value of "container/name". > > Other than subsequently tweaking the HTML code manually (but doesn't > that defeat one of the goals of ZPT?), how can we be sure that the TAL > statements will be on the appropriate (i.e. innermost) tag after > compound styling has been applied? Or is there a way to have a > "tal:content" statement affect only the innermost content? And if not, > ought there to be? > > Hamish Lawson Thanks -- that's an interesting real-life observation. I think there may be no easy answer, but you could try to put the TAL attributes on a tag *inside* the elements... --Guido van Rossum (home page: http://www.python.org/~guido/) From hamish_lawson@yahoo.co.uk Thu Apr 5 22:23:29 2001 From: hamish_lawson@yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Thu, 5 Apr 2001 22:23:29 +0100 (BST) Subject: [ZPT] Authoring tools and tag-nesting problems In-Reply-To: <200104052155.QAA11260@cj20424-a.reston1.va.home.com> Message-ID: <20010405212329.1530.qmail@web216.mail.yahoo.com> Hello Guido, I wrote: When I edited this template in Dreamweaver UltraDev ... I found that the resulting HTML was: Joe That is, Dreamweaver applied the tag just to "Joe" and not around the bold tags enclosing the text ... You replied: I think there may be no easy answer, but you could try to put the TAL attributes on a tag *inside* the elements... Thanks for the suggestion. I don't have Dreamweaver here to try that out (I'll check it out back at work), but I suspect that even if I were to do that, subsequent styling of the text may put a tag inside your tag; as before, this later tag would then be lost when the template was rendered. Regards, Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From evan@digicool.com Thu Apr 5 22:40:59 2001 From: evan@digicool.com (Evan Simpson) Date: Thu, 5 Apr 2001 16:40:59 -0500 Subject: [ZPT] Authoring tools and tag-nesting problems References: <20010405200620.15424.qmail@web214.mail.yahoo.com> Message-ID: <014101c0be19$1ba7b750$2a04000a@evansys> From: "Hamish Lawson" > I had a template with the following snippet: > > Joe > > When I edited this template in Dreamweaver UltraDev and applied a > subtle shade of pink to "Joe", I found that the resulting HTML was: > > Joe This is a tough one. We may not be able to do anything more reasonable here than warn people if they have tags inside of a tal:content="text" statement tag. Cheers, Evan @ digicool From chrisw@nipltd.com Thu Apr 5 22:50:06 2001 From: chrisw@nipltd.com (Chris Withers) Date: Thu, 5 Apr 2001 22:50:06 +0100 Subject: [ZPT] Authoring tools and tag-nesting problems References: <20010405212329.1530.qmail@web216.mail.yahoo.com> Message-ID: <002d01c0be1a$627b0370$36fa7ad5@withers> > Thanks for the suggestion. I don't have Dreamweaver here to try that > out (I'll check it out back at work), but I suspect that even if I were > to do that, subsequent styling of the text may put a tag inside your > tag; as before, this later tag would then be lost when the > template was rendered. The other option, and I know this is far from perfect, would be to use CSS rather than things like FONT tags to do your styling. Dunno how Dreamweaver or GoLive fair with this though, not to mention browsers... cheers, Chris From richard@bizarsoftware.com.au Fri Apr 6 01:11:57 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Fri, 06 Apr 2001 10:11:57 +1000 Subject: [ZPT] :) Sorry for being so noisy ;) Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From guido@digicool.com Fri Apr 6 01:56:31 2001 From: guido@digicool.com (guido@digicool.com) Date: Thu, 5 Apr 2001 20:56:31 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmltalparser.py:1.9 Message-ID: <20010406005631.D736E51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv4247 Modified Files: test_htmltalparser.py Log Message: Add tests for various TALError and METALError exceptions. --- Updated File test_htmltalparser.py in package Packages/TAL -- --- test_htmltalparser.py 2001/03/29 00:56:58 1.8 +++ test_htmltalparser.py 2001/04/06 00:56:29 1.9 @@ -8,7 +8,7 @@ import unittest from TAL import HTMLTALParser -from TAL.TALDefs import TAL_VERSION +from TAL.TALDefs import TAL_VERSION, TALError, METALError class TestCaseBase(unittest.TestCase): @@ -40,7 +40,13 @@ pprint.pprint(got_program) pprint.pprint(got_macros) + def _should_error(self, source, exc=TALError): + def parse(self=self, source=source): + parser = HTMLTALParser.HTMLTALParser() + parser.parseString(self.prologue + source + self.epilogue) + self.assertRaises(exc, parse) + class HTMLTALParserTestCases(TestCaseBase): def check_code_simple_identity(self): @@ -349,6 +355,32 @@ ('rawtext', '

')]), ]) + def check_dup_attr(self): + self._should_error("") + self._should_error("", METALError) + + def check_tal_errors(self): + self._should_error("

") + self._should_error("

") + self._should_error("

") + self._should_error("

") + self._should_error("

") + self._should_error("

") + self._should_error("

") + + def check_metal_errors(self): + exc = METALError + self._should_error(2*"

xxx

", exc) +## self._should_error("" + +## 2*"

" + "") + self._should_error("" + + 2*"

" + "", exc) + self._should_error("

", exc) + self._should_error("

", + exc) + self._should_error("

", exc) + def test_suite(): suite = unittest.TestSuite() From guido@digicool.com Fri Apr 6 01:59:47 2001 From: guido@digicool.com (guido@digicool.com) Date: Thu, 5 Apr 2001 20:59:47 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALGenerator.py:1.30 Message-ID: <20010406005947.1D6FD51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv4825 Modified Files: TALGenerator.py Log Message: Fix bug reported by Richard Jones in ZPT(19). Also fix the error for a duplicate fill-slot (which was erroneously reported as a duplicate slot *definition*). Question arises, should we also complain about duplicate define-slot, or is it okay to use define-slot with the same name more than once? This would be similar to "#define X(a) (a+a)" in C; it does point out that define-slot isn't a great name... --- Updated File TALGenerator.py in package Packages/TAL -- --- TALGenerator.py 2001/03/27 16:57:59 1.29 +++ TALGenerator.py 2001/04/06 00:59:45 1.30 @@ -245,7 +245,7 @@ def emitRepeat(self, arg, position=(None, None)): m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg) if not m: - raise TALError("invalid repeat syntax: " + `repeat`, position) + raise TALError("invalid repeat syntax: " + `arg`, position) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() @@ -281,7 +281,7 @@ def emitFillSlot(self, slotName, position=(None, None)): program = self.popProgram() if self.slots.has_key(slotName): - raise METALError("duplicate slot definition: %s" % slotName, + raise METALError("duplicate fill-slot name: %s" % slotName, position) self.slots[slotName] = program self.emit("fillSlot", slotName, program) From guido@digicool.com Fri Apr 6 02:00:17 2001 From: guido@digicool.com (guido@digicool.com) Date: Thu, 5 Apr 2001 21:00:17 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALInterpreter.py:1.30 Message-ID: <20010406010017.D7CB451014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv4912 Modified Files: TALInterpreter.py Log Message: Remove unused import of TALError. --- Updated File TALInterpreter.py in package Packages/TAL -- --- TALInterpreter.py 2001/03/27 11:46:01 1.29 +++ TALInterpreter.py 2001/04/06 01:00:16 1.30 @@ -96,7 +96,7 @@ except ImportError: from StringIO import StringIO -from TALDefs import TALError, quote, TAL_VERSION +from TALDefs import quote, TAL_VERSION from TALGenerator import TALGenerator BOOLEAN_HTML_ATTRS = [ From guido@digicool.com Fri Apr 6 03:08:38 2001 From: guido@digicool.com (Guido van Rossum) Date: Thu, 05 Apr 2001 21:08:38 -0500 Subject: [ZPT] , ignoring any markup in between)? I basically learned HTML when it was small and elegant, and I have no idea what , ignoring any markup in between)? I basically learned > HTML when it was small and elegant, and I have no idea what . Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Fri Apr 6 02:46:27 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Fri, 06 Apr 2001 11:46:27 +1000 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> Message-ID: <3ACD1FF3.C121386F@bizarsoftware.com.au> richard@bizarsoftware.com.au wrote: > > Evan Simpson wrote: > > > > Here's two ideas I had while using ZPT today: > > > > 1. Suppose that I want to replace a tag, but only if the replacement > > value exists, otherwise I want to keep the dummy text. Right now, this > > is the best I can do: > > > > > tal:replace="request/foo"> > > The Text > > > > Ditto for 'content' and 'attributes'. This isn't that bad, but I > > thought about extending 'condition', so that you could write: > > > > > tal:replace="request/foo">The Text > > Another approach would be to have the condition be able to break out of the > processing for that tag if it fails, and not remove the tag. Something > like: > > tal:replace="request/foo">The Text > > Or maybe a whole new TAL statement is required? > > tal:replace="request/foo">The Text > > or > > The Text > > Perhaps what we really want is a way for replace to fail gracefully? > > The Text > > My favourite is a tie between the last two... They're probably easier to > actually implement, and it's much more obvious what they're doing. Not that > we'd have to go with 'only_if_exists' as the actual keyword ;) Just a note: I've implemented a "lazy" keyword so that one can: The Text I currently have a patched Expressions.py using Shane's fixes to restrictedTraverse, so a diff to provide this functionality is going to be unusable. In short though, I modified installHandlers so 'lazy' is recognised, and added a clause to the "except (AttributeError, KeyError):" in PathExpr.__call__ with "if self._name == 'lazy': return None". This works a treat for me - I use it in tal:attributes and tal:replace at the moment. Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Fri Apr 6 02:50:36 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Fri, 06 Apr 2001 11:50:36 +1000 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> Message-ID: <3ACD20EC.75F05C73@bizarsoftware.com.au> richard@bizarsoftware.com.au wrote: > richard@bizarsoftware.com.au wrote: > > Evan Simpson wrote: > > > > > > Here's two ideas I had while using ZPT today: > > > > > > 1. Suppose that I want to replace a tag, but only if the replacement > > > value exists, otherwise I want to keep the dummy text. Right now, this > > > is the best I can do: > > > > > > > > tal:replace="request/foo"> > > > The Text > > Just a note: I've implemented a "lazy" keyword so that one can: > > The Text > > > I currently have a patched Expressions.py using Shane's fixes to > restrictedTraverse, so a diff to provide this functionality is going to be > unusable. In short though, I modified installHandlers so 'lazy' is > recognised, and added a clause to the "except (AttributeError, KeyError):" > in PathExpr.__call__ with "if self._name == 'lazy': return None". > > This works a treat for me - I use it in tal:attributes and tal:replace at > the moment. Oops - just realised that the replace behaviour isn't what Evan wanted... The lazy evaluation is still a very big bonus though. Hrmm... Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From mindlace@digicool.com Fri Apr 6 02:57:16 2001 From: mindlace@digicool.com (ethan mindlace fremen) Date: Thu, 05 Apr 2001 21:57:16 -0400 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: <3ACD1FF3.C121386F@bizarsoftware.com.au> Message-ID: <401000000.986522236@progeny> --On Friday, April 06, 2001 11:46:27 +1000 richard@bizarsoftware.com.au wrote: > Just a note: I've implemented a "lazy" keyword so that one can: > > The Text > Richard - you're my hero. I can't count the number of times I've done or value="&dtml-foo;". Yay! -- -mindlace- zopatista community liason From Geir Bækholt Fri Apr 6 12:01:04 2001 From: Geir Bækholt (Geir Bækholt) Date: Fri, 6 Apr 2001 13:01:04 +0200 Subject: [ZPT] nesting macros with slots ? Message-ID: <14790740578.20010406130104@funcom.com> how would one go forth to nest macros with slots in them ? say : including someMacroWithASlot in a commonLookAndFeel template , and letting the slot in someMacroWithASlot be editable for pages using commonLookAndFeel as a template.. ? -- Geir Bækholt web-developer/designer geirh@funcom.com http://www.funcom.com From guido@digicool.com Fri Apr 6 16:10:00 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 10:10:00 -0500 Subject: [ZPT] nesting macros with slots ? In-Reply-To: Your message of "Fri, 06 Apr 2001 13:01:04 +0200." <14790740578.20010406130104@funcom.com> References: <14790740578.20010406130104@funcom.com> Message-ID: <200104061510.KAA14276@cj20424-a.reston1.va.home.com> > how would one go forth to nest macros with slots in them ? > > say : > including someMacroWithASlot in a commonLookAndFeel template > , and letting the slot in someMacroWithASlot be editable for pages > using commonLookAndFeel as a template.. > > ? Sorry, I don't understand what you want to do. Do you want to nest macro *definitions* or macro *calls*? You can nest calls without problems. You may even be able to nest definitions! But it would all be much clearer for me if you could give an explicit example of what you want to do. --Guido van Rossum (home page: http://www.python.org/~guido/) From shane@digicool.com Fri Apr 6 15:23:52 2001 From: shane@digicool.com (shane@digicool.com) Date: Fri, 6 Apr 2001 10:23:52 -0400 (EDT) Subject: [ZPT] CVS: Packages/Products/PageTemplates (Products/DC/PageTemplates) - TALES.py:1.4 PageTemplate.py:1.5 Message-ID: <20010406142352.54EFB51014@korak.digicool.com> Update of /cvs-repository/Packages/Products/PageTemplates In directory korak:/tmp/cvs-serv30666 Modified Files: TALES.py PageTemplate.py Log Message: Made runtime exceptions more readable. --- Updated File TALES.py in package Packages/Products/PageTemplates -- --- TALES.py 2001/03/29 10:22:33 1.3 +++ TALES.py 2001/04/06 14:23:50 1.4 @@ -255,7 +255,7 @@ try: return expression(self) except: - raise TALESError, (`expression`, sys.exc_info()) + raise TALESError, (`expression`, sys.exc_info()), sys.exc_info()[2] evaluateValue = evaluate --- Updated File PageTemplate.py in package Packages/Products/PageTemplates -- --- PageTemplate.py 2001/03/29 10:21:56 1.4 +++ PageTemplate.py 2001/04/06 14:23:50 1.5 @@ -145,7 +145,7 @@ output = StringIO() c = self.pt_getContext() c.update(extra_context) - __traceback_info__ = c + #__traceback_info__ = c TALInterpreter(self._v_program, self._v_macros, getEngine().getContext(c), From shane@digicool.com Fri Apr 6 15:26:57 2001 From: shane@digicool.com (shane@digicool.com) Date: Fri, 6 Apr 2001 10:26:57 -0400 (EDT) Subject: [ZPT] CVS: Packages/Products/PageTemplates (Products/DC/PageTemplates) - Expressions.py:1.5 Message-ID: <20010406142657.72D5851014@korak.digicool.com> Update of /cvs-repository/Packages/Products/PageTemplates In directory korak:/tmp/cvs-serv31080 Modified Files: Expressions.py Log Message: - Fixed mistake in restrictedTraverse() security. - Made ZPT invoke DTML the normal way. --- Updated File Expressions.py in package Packages/Products/PageTemplates -- --- Expressions.py 2001/03/27 15:10:09 1.4 +++ Expressions.py 2001/04/06 14:26:56 1.5 @@ -95,6 +95,7 @@ from TALES import Engine, CompilerError, _valid_name, NAME_RE from string import strip, split, join, replace, lstrip from DocumentTemplate.DT_Util import TemplateDict +from Acquisition import aq_base _engine = None def getEngine(): @@ -114,6 +115,24 @@ reg('not', NotExpr) reg('import', ImportExpr) +def render(ob): + """ + Calls the object, possibly a document template, or just returns it if + not callable. (From DT_Util.py) + """ + base = aq_base(ob) + if callable(base): + try: + if getattr(base, 'isDocTemp', 0): + ob = ob(ob, ob.REQUEST) + else: + ob = ob() + except AttributeError, n: + if n != '__call__': + raise + return ob + + class PathExpr: def __init__(self, name, expr): self._s = expr @@ -158,10 +177,7 @@ return 1 if self._name == 'nocall': return ob - mm = TemplateDict() - mm._push(var) - mm._push({'_ob': ob}) - return mm['_ob'] + return render(ob) def __str__(self): return '%s expression "%s"' % (self._name, self._s) @@ -310,6 +326,8 @@ if not path: return self + __traceback_info__ = path + get=getattr N=None M=[] #marker @@ -335,7 +353,7 @@ raise 'NotFound', name if name=='..': - o=getattr(object, 'aq_parent', M) + o = getattr(object, 'aq_parent', M) if o is not M: if not securityManager.validate(object, object, name, o): raise 'Unauthorized', name @@ -354,19 +372,13 @@ else: o=get(object, name, M) if o is not M: - # waaaa - if hasattr(get(object,'aq_base',object), name): - # value wasn't acquired - if not securityManager.validate( - object, object, name, o): - raise 'Unauthorized', name - pass + # Check security. + if hasattr(object, 'aq_acquire'): + object.aq_acquire( + name, validate2, securityManager.validate) else: - if not securityManager.validate( - object, None, name, o): + if not securityManager.validate(object, object, name, o): raise 'Unauthorized', name - pass - else: o=object[name] if not securityManager.validate(object, object, None, o): @@ -374,3 +386,9 @@ object = o return object + + +def validate2(orig, inst, name, v, real_validate): + if not real_validate(orig, inst, name, v): + raise 'Unauthorized', name + return 1 From guido@digicool.com Fri Apr 6 17:23:31 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 11:23:31 -0500 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: Your message of "Fri, 06 Apr 2001 11:50:36 +1000." <3ACD20EC.75F05C73@bizarsoftware.com.au> References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> Message-ID: <200104061623.LAA14679@cj20424-a.reston1.va.home.com> The general problem in this thread seems to be that TAL (like DTML?) doesn't have an "else" construct. Could we add one, e.g. as follows:

Text if foo is set

Text if foo is not set

You could have any number of else-condition statements following a condition statement, just like Python's if...elif...elif...; the first one whose expression evaluates to true is taken. To spell plain else, the last one can have an empty condition. Problem with this: how do you know which condition a given else-condition belongs to? Should the elements be adjacent except for whitespace? --Guido van Rossum (home page: http://www.python.org/~guido/) From evan@digicool.com Fri Apr 6 17:03:36 2001 From: evan@digicool.com (Evan Simpson) Date: Fri, 6 Apr 2001 11:03:36 -0500 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> Message-ID: <02d801c0beb3$246fbd20$2a04000a@evansys> From: "Guido van Rossum" > The general problem in this thread seems to be that TAL (like DTML?) > doesn't have an "else" construct. Could we add one, e.g. as follows: The reason for that (beyond the awkwardness of trying to spell alternate branches in attribute language) is that anything more complex than on/off or replace/don't behavior violates the WYSIWYG principle of ZPT. In other words, when you are viewing template source, it is easy to visualize the effect of omitting an element, and trivially easy to see the effect of leaving an element unchanged. On the other hand, placing multiple versions of an element side-by-side is likely to distort the page. This is the problem that we intended to address with "modes", and may be able to implement with switchable macro references. Cheers, Evan @ digicool From mindlace@digicool.com Fri Apr 6 17:11:14 2001 From: mindlace@digicool.com (ethan mindlace fremen) Date: Fri, 06 Apr 2001 12:11:14 -0400 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: <200104061623.LAA14679@cj20424-a.reston1.va.home.com> Message-ID: <56520000.986573474@mindlace.digicool.com> --On Friday, April 06, 2001 11:23:31 -0500 Guido van Rossum wrote: > The general problem in this thread seems to be that TAL (like DTML?) > doesn't have an "else" construct. DTML has an else construct that almost always destroys the well-formedness of a page and is a bit odd in that it is a singleton tag in a regular tag. > Could we add one, e.g. as follows: > >

Text if foo is set

>

Text if foo is not set

> > You could have any number of else-condition statements following a > condition statement, just like Python's if...elif...elif...; While something like this would be cool, I really, really want lazy inserts. I'm tired of having to code around KeyErrors. Plus, how would you do else on tal:attributes? -- ethan mindlace fremen zopatista community liason From guido@digicool.com Fri Apr 6 18:55:48 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 12:55:48 -0500 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: Your message of "Fri, 06 Apr 2001 11:03:36 EST." <02d801c0beb3$246fbd20$2a04000a@evansys> References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> Message-ID: <200104061755.MAA15211@cj20424-a.reston1.va.home.com> > From: "Guido van Rossum" > > The general problem in this thread seems to be that TAL (like DTML?) > > doesn't have an "else" construct. Could we add one, e.g. as follows: > > The reason for that (beyond the awkwardness of trying to spell alternate > branches in attribute language) is that anything more complex than > on/off or replace/don't behavior violates the WYSIWYG principle of ZPT. > In other words, when you are viewing template source, it is easy to > visualize the effect of omitting an element, and trivially easy to see > the effect of leaving an element unchanged. On the other hand, placing > multiple versions of an element side-by-side is likely to distort the > page. > > This is the problem that we intended to address with "modes", and may be > able to implement with switchable macro references. Maybe, but your initial post here *wanted* an else, and you solved it with two conditions, the second being the reverse of the first. That also violates the WYSIWYG principle. Given that this is probably a common request, what are we going to *do* about it? All solutions are hacks! (My own solution uses on-error :-). --Guido van Rossum (home page: http://www.python.org/~guido/) From bitz@bitdance.com Fri Apr 6 19:18:11 2001 From: bitz@bitdance.com (R. David Murray ) Date: Fri, 6 Apr 2001 14:18:11 -0400 (EDT) Subject: [ZPT] My First Post In-Reply-To: <3ACA71B0.517CA450@bizarsoftware.com.au> Message-ID: On Wed, 4 Apr 2001 richard@bizarsoftware.com.au wrote: > TAL statements: define, attributes, condition, content, replace, repeat > - why is attributes plural? It may be used to define a single attribute > replacement. Similarly, define may be used for either a single or multiple > definition. So as far as I'm concerned, attributes should just be > attribute. Or define should be definitions. One or the other. Or is it just > Too Late to be bringing this stuff up? IMO, the spelling used is correct. 'define' is a verb, whereas 'attributes' is a noun. At least, that's the way I hear it . --RDM From evan@digicool.com Fri Apr 6 20:23:25 2001 From: evan@digicool.com (Evan Simpson) Date: Fri, 6 Apr 2001 14:23:25 -0500 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> Message-ID: <003601c0becf$0db27200$2a04000a@evansys> From: "Guido van Rossum" > Maybe, but your initial post here *wanted* an else, and you solved it > with two conditions, the second being the reverse of the first. That > also violates the WYSIWYG principle. I only did that because we didn't have a way to spell "leave the example text alone". The lazy: proposal looks like it may be a decent spelling, especially if we can come up with a better name for it ;-) Cheers, Evan @ digicool From guido@digicool.com Fri Apr 6 21:44:13 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 15:44:13 -0500 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: Your message of "Fri, 06 Apr 2001 14:23:25 EST." <003601c0becf$0db27200$2a04000a@evansys> References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> Message-ID: <200104062044.PAA15797@cj20424-a.reston1.va.home.com> > From: "Guido van Rossum" > > Maybe, but your initial post here *wanted* an else, and you solved it > > with two conditions, the second being the reverse of the first. That > > also violates the WYSIWYG principle. > > I only did that because we didn't have a way to spell "leave the example > text alone". The lazy: proposal looks like it may be a decent spelling, > especially if we can come up with a better name for it ;-) I'm not sure about the semantics of "lazy:...". I thought that it was supposed to return None when the evaluation fails. But that would replace the element with nothing, not leave the default text in place (for that, you'd have to modify TALInterpreter, I believe). The on-error="string:default text" hack is beginning to look better... --Guido van Rossum (home page: http://www.python.org/~guido/) From fred@digicool.com Fri Apr 6 20:54:19 2001 From: fred@digicool.com (fred@digicool.com) Date: Fri, 6 Apr 2001 15:54:19 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmltalparser.py:1.10 Message-ID: <20010406195419.8874051014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv16835 Modified Files: test_htmltalparser.py Log Message: Revise a test that requires "" to be accepted -- it is not! --- Updated File test_htmltalparser.py in package Packages/TAL -- --- test_htmltalparser.py 2001/04/06 00:56:29 1.9 +++ test_htmltalparser.py 2001/04/06 19:54:18 1.10 @@ -96,8 +96,8 @@ """""", [ ('rawtext', '')]) - self._run_check("""""", [ - ('rawtext', ''), + self._run_check("""""", [ + ('rawtext', ''), ]) def check_code_attr_entity_replacement(self): From fred@digicool.com Fri Apr 6 20:55:25 2001 From: fred@digicool.com (fred@digicool.com) Date: Fri, 6 Apr 2001 15:55:25 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmlparser.py:1.11 Message-ID: <20010406195525.0522351014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv17153 Modified Files: test_htmlparser.py Log Message: Revise a test that requires "" to be accepted -- it is not! Add a check to ensure it raises an HTMLParseError. --- Updated File test_htmlparser.py in package Packages/TAL -- --- test_htmlparser.py 2001/03/29 00:02:21 1.10 +++ test_htmlparser.py 2001/04/06 19:55:23 1.11 @@ -162,8 +162,8 @@ ("c", "yyy\t\nyyy"), ("d", "\txyz\n")]) ]) - self._run_check("""""", [ - ("starttag", "a", [("b", ""), ("c", ""), ("d", "")]), + self._run_check("""""", [ + ("starttag", "a", [("b", ""), ("c", "")]), ]) def check_attr_entity_replacement(self): @@ -216,6 +216,7 @@ self._parse_error("'") self._parse_error("]+)*/?>") +locatestarttagend = re.compile(r""" + <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name + (?:\s+ # whitespace before attribute name + (?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name + (?:\s*=\s* # value indicator + (?:'[^']*' # LITA-enclosed value + |\"[^\"]*\" # LIT-enclosed value + |[^'\">\s]+ # bare value + ) + )? + ) + )* + \s* # trailing whitespace +""", re.VERBOSE) endstarttag = re.compile(r"\s*/?>") endendtag = re.compile('>') endtagfind = re.compile('') @@ -45,7 +58,7 @@ """Exception raised for all parse errors.""" def __init__(self, msg, position=(None, None)): - assert msg != "" + assert msg self.msg = msg self.lineno = position[0] self.offset = position[1] @@ -255,11 +268,10 @@ # Internal -- handle starttag, return end or -1 if not terminated def parse_starttag(self, i): self.__starttag_text = None + endpos = self.check_for_whole_start_tag(i) + if endpos < 0: + return endpos rawdata = self.rawdata - m = locatestarttagend.match(rawdata, i) # > outside quotes - if not m: - return -1 - endpos = m.end() self.__starttag_text = rawdata[i:endpos] # Now parse the data between i+1 and j into a tag and attrs @@ -301,6 +313,29 @@ else: self.handle_starttag(tag, attrs) return endpos + + # Internal -- check to see if we have a complete starttag; return end + # or -1 if incomplete. + def check_for_whole_start_tag(self, i): + rawdata = self.rawdata + m = locatestarttagend.match(rawdata, i) + if m: + j = m.end() + next = rawdata[j:j+1] + if next == ">": + return j + 1 + if rawdata[j:j+2] == "/>": + return j + 2 + if next == "": + # end of input + return -1 + if next in ("abcdefghijklmnopqrstuvwxyz=" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): + # end of input in or before attribute value + return -1 + self.updatepos(i, j) + raise HTMLParseError("malformed start tag", self.getpos()) + raise AssertionError("we should not gt here!") # Internal -- parse endtag, return end or -1 if incomplete def parse_endtag(self, i): From evan@digicool.com Fri Apr 6 22:23:00 2001 From: evan@digicool.com (Evan Simpson) Date: Fri, 6 Apr 2001 16:23:00 -0500 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> Message-ID: <008e01c0bedf$c42dbc50$2a04000a@evansys> From: "Guido van Rossum" > I'm not sure about the semantics of "lazy:...". I thought that it was > supposed to return None when the evaluation fails. But that would > replace the element with nothing, not leave the default text in place > (for that, you'd have to modify TALInterpreter, I believe). The sort of thing I'm thinking of, call it "if:", would evaluate it's expression and catch any traversal errors (traversal would be modified to raise a new exception if a step failed in any way). On such an error, it would return (or raise) doNothing. TALInterpreter would be modified so that 'content', 'replace', and 'attributes' would do nothing if they receive this signal. That way we could write:

It isn't here.

If "path:request/might_be_here" resolves, then its value replaces the paragraph content, otherwise the default text remains. Likewise:
Go here "if::" could also be "optional:", or whatever. Cheers, Evan @ digicool From guido@digicool.com Fri Apr 6 23:28:03 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 17:28:03 -0500 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: Your message of "Fri, 06 Apr 2001 16:23:00 EST." <008e01c0bedf$c42dbc50$2a04000a@evansys> References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> Message-ID: <200104062228.RAA16537@cj20424-a.reston1.va.home.com> > The sort of thing I'm thinking of, call it "if:", would evaluate it's > expression and catch any traversal errors (traversal would be modified > to raise a new exception if a step failed in any way). On such an > error, it would return (or raise) doNothing. TALInterpreter would be > modified so that 'content', 'replace', and 'attributes' would do nothing > if they receive this signal. That way we could write: > >

It isn't here.

> > If "path:request/might_be_here" resolves, then its value replaces the > paragraph content, otherwise the default text remains. Likewise: > > Go here > > "if::" could also be "optional:", or whatever. OK, good. Now I understand. Should we do this for 1.1? (It's not hard!) --Guido van Rossum (home page: http://www.python.org/~guido/) From guido@digicool.com Fri Apr 6 22:33:27 2001 From: guido@digicool.com (guido@digicool.com) Date: Fri, 6 Apr 2001 17:33:27 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 Message-ID: <20010406213327.F35B851014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv32281 Modified Files: README.txt Log Message: Add content model correctly (i.e. recognize + no other tags, entities etc.). From evan@digicool.com Fri Apr 6 22:38:42 2001 From: evan@digicool.com (Evan Simpson) Date: Fri, 6 Apr 2001 16:38:42 -0500 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> Message-ID: <00aa01c0bee1$f39919b0$2a04000a@evansys> From: "Guido van Rossum" > OK, good. Now I understand. Should we do this for 1.1? (It's not > hard!) I think so. I should put it in the fishbowl, though, and I need to rearrange the fishbowl so that post-1.0 proposals are cleanly separated from the description of 1.0. Cheers, Evan @ digicool From guido@digicool.com Fri Apr 6 22:35:04 2001 From: guido@digicool.com (guido@digicool.com) Date: Fri, 6 Apr 2001 17:35:04 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALInterpreter.py:1.31 Message-ID: <20010406213504.DE4BE51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv32507 Modified Files: TALInterpreter.py Log Message: Change attribute replacement so that Boolean HTML attributes can be set or cleared by specifying any true or false value. (XXX I wonder if this should be recognized at compile time rather than at interpretation time; oh well, this works.) --- Updated File TALInterpreter.py in package Packages/TAL -- --- TALInterpreter.py 2001/04/06 01:00:16 1.30 +++ TALInterpreter.py 2001/04/06 21:35:03 1.31 @@ -252,15 +252,19 @@ if len(item) > 2: action = item[2] if action == "replace" and len(item) > 3 and self.tal: - value = self.engine.evaluateText(item[3]) + if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: + ok = self.engine.evaluateBoolean(item[3]) + if not ok: + continue + else: + value = None + else: + value = self.engine.evaluateText(item[3]) elif (action == "macroHack" and self.currentMacro and name[-13:] == ":define-macro" and self.metal): name = name[:-13] + ":use-macro" value = self.currentMacro - if (self.html and not value and - string.lower(name) in BOOLEAN_HTML_ATTRS): - s = name - elif value is None: + if value is None: s = name else: s = "%s=%s" % (name, quote(value)) From guido@digicool.com Fri Apr 6 23:39:16 2001 From: guido@digicool.com (Guido van Rossum) Date: Fri, 06 Apr 2001 17:39:16 -0500 Subject: [ZPT] Extending tal:condition, making metal:define In-Reply-To: Your message of "Fri, 06 Apr 2001 16:38:42 EST." <00aa01c0bee1$f39919b0$2a04000a@evansys> References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> <00aa01c0bee1$f39919b0$2a04000a@evansys> Message-ID: <200104062239.RAA21549@cj20424-a.reston1.va.home.com> > From: "Guido van Rossum" > > OK, good. Now I understand. Should we do this for 1.1? (It's not > > hard!) > > I think so. I should put it in the fishbowl, though, and I need to > rearrange the fishbowl so that post-1.0 proposals are cleanly separated > from the description of 1.0. OK, go ahead. What's the timeline for the 1.1 release? Can I go ahead and implement suppression of TAL/METAL attributes when doing TAL expansion, or should that go through the fishbowl too? --Guido van Rossum (home page: http://www.python.org/~guido/) From guido@digicool.com Fri Apr 6 22:38:25 2001 From: guido@digicool.com (guido@digicool.com) Date: Fri, 6 Apr 2001 17:38:25 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test12.html:1.1 Message-ID: <20010406213825.A9F3A51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test/input In directory korak:/tmp/cvs-serv664/input Added Files: test12.html Log Message: Add test cases for HTML Boolean attribute substitution. --- Added File test12.html in package Packages/TAL --- From guido@digicool.com Fri Apr 6 22:38:26 2001 From: guido@digicool.com (guido@digicool.com) Date: Fri, 6 Apr 2001 17:38:26 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test12.html:1.1 Message-ID: <20010406213826.14EE0510E2@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test/output In directory korak:/tmp/cvs-serv664/output Added Files: test12.html Log Message: Add test cases for HTML Boolean attribute substitution. --- Added File test12.html in package Packages/TAL --- From evan@digicool.com Fri Apr 6 22:44:54 2001 From: evan@digicool.com (Evan Simpson) Date: Fri, 6 Apr 2001 16:44:54 -0500 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> <00aa01c0bee1$f39919b0$2a04000a@evansys> <200104062239.RAA21549@cj20424-a.reston1.va.home.com> Message-ID: <00c201c0bee2$d1bdff30$2a04000a@evansys> From: "Guido van Rossum" > OK, go ahead. What's the timeline for the 1.1 release? Can I go > ahead and implement suppression of TAL/METAL attributes when doing TAL > expansion, or should that go through the fishbowl too? Go ahead; We really intended it to be that way from the start, but it got lost in the excitement. I plan to do a 1.01 bugfix release Monday, since there are major PageTemplates bugs in 1.0. At the same time, I'll groom the Wiki for 1.1 discussion, with the idea of doing a beta the following Monday if that looks reasonable. Cheers, Evan @ digicool From fred@digicool.com Fri Apr 6 23:19:16 2001 From: fred@digicool.com (fred@digicool.com) Date: Fri, 6 Apr 2001 18:19:16 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmlparser.py:1.12 Message-ID: <20010406221916.52C3651014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv6938 Modified Files: test_htmlparser.py Log Message: Added a test case to make sure """ + self._run_check(s, [ + ("starttag", "script", []), + ("data", " ¬-an-entity-ref; "), + ("endtag", "script"), + ]) + s = """""" + self._run_check(s, [ + ("starttag", "script", []), + ("data", " "), + ("endtag", "script"), + ]) + # Support for the Zope regression test framework: def test_suite(): From fred@digicool.com Fri Apr 6 23:23:32 2001 From: fred@digicool.com (fred@digicool.com) Date: Fri, 6 Apr 2001 18:23:32 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLParser.py:1.13 Message-ID: <20010406222332.BE04151014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv7643 Modified Files: HTMLParser.py Log Message: Add general support for CDATA element content, enabled by default for content model correctly (i.e. recognize - no other tags, entities etc.). From guido@digicool.com Sat Apr 7 20:25:05 2001 From: guido@digicool.com (guido@digicool.com) Date: Sat, 7 Apr 2001 15:25:05 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLTALParser.py:1.26 README.txt:1.16 TALDefs.py:1.15 TALInterpreter.py:1.32 TALParser.py:1.13 driver.py:1.20 Message-ID: <20010407192505.CAFD951014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv4976 Modified Files: HTMLTALParser.py README.txt TALDefs.py TALInterpreter.py TALParser.py driver.py Log Message: Changes to suppress TAL attributes (and METAL attributes, and selected XMLNS attributes) in rendered output, with an option to keep the old behavior. HTMLTALParser.py, TALParser.py: Mark TAL, METAL and TAL/METAL-related XMLNS attributes in the attribute list; the old macroHack marking is subsumed in this. The marking is a third value in the list item describing the attribute, saying "tal", "metal" or "xmlns". All TAL and METAL attributes are marked; only XMLNS attributes whose namespace URI value is the special marker for TAL or METAL are marked. TALInterpreter.py: - Get rid of the non-functional 'html' keyword argument. - Add new 'showtal' keyword argument to constructor; this defaults to -1, which means that the value should default to 0 if TAL expansion is requested (through the 'tal' keyword argument) and 1 if TAL expansion is not requested. - In do_startEndTag(), don't special-case empty HTML tags; this is already taken care of by TALGenerator. - Implement the showtal behavior: when this flag is false, don't output TAL, METAL and XMLNS attributes (that are marked as such by the parser). - Fix a bug: should render as , not as . TALDefs.py: Bumped TAL_VERSION to "1.0.1" driver.py: New command line option -t to show tal in output README.txt: Update TO DO list. --- Updated File HTMLTALParser.py in package Packages/TAL -- --- HTMLTALParser.py 2001/03/27 17:23:26 1.25 +++ HTMLTALParser.py 2001/04/07 19:25:03 1.26 @@ -317,15 +317,16 @@ if metaldict.has_key(suffix): raise METALError("duplicate METAL attribute " + `suffix`, self.getpos()) - item = (key, value) + item = (key, value, "metal") metaldict[suffix] = value - if suffix == "define-macro": - item = (key,value,"macroHack") elif nsuri == ZOPE_TAL_NS: if taldict.has_key(suffix): raise TALError("duplicate TAL attribute " + `suffix`, self.getpos()) - item = (key, value) + item = (key, value, "tal") taldict[suffix] = value + elif (prefix == "xmlns" and + value in (ZOPE_METAL_NS, ZOPE_TAL_NS)): + item = (key, value, "xmlns") attrlist.append(item) return attrlist, taldict, metaldict --- Updated File README.txt in package Packages/TAL -- --- README.txt 2001/04/07 02:01:08 1.15 +++ README.txt 2001/04/07 19:25:03 1.16 @@ -91,6 +91,3 @@ tal:replace and tal:attributes should not be required to do attribute replacement on the inserted text -- this would require a change to the TAL spec though. - -- In rendered HTML or XML, the TAL attributes should be suppressed. - (Effectively, when TALInterpreter is invoked with tal=1.) --- Updated File TALDefs.py in package Packages/TAL -- --- TALDefs.py 2001/03/26 17:02:50 1.14 +++ TALDefs.py 2001/04/07 19:25:03 1.15 @@ -86,7 +86,7 @@ Common definitions used by TAL and METAL compilation an transformation. """ -TAL_VERSION = "1.0" +TAL_VERSION = "1.0.1" XML_NS = "http://www.w3.org/XML/1998/namespace" # URI for XML namespace XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations --- Updated File TALInterpreter.py in package Packages/TAL -- --- TALInterpreter.py 2001/04/06 21:35:03 1.31 +++ TALInterpreter.py 2001/04/07 19:25:03 1.32 @@ -150,7 +150,7 @@ class TALInterpreter: def __init__(self, program, macros, engine, stream=None, - debug=0, wrap=60, metal=1, tal=1, html=0): + debug=0, wrap=60, metal=1, tal=1, showtal=-1): self.program = program self.macros = macros self.engine = engine @@ -160,7 +160,11 @@ self.wrap = wrap self.metal = metal self.tal = tal - self.html = html + assert showtal in (-1, 0, 1) + if showtal == -1: + showtal = (not tal) + self.showtal = showtal + self.html = 0 self.slots = {} self.currentMacro = None self.position = None, None # (lineno, offset) @@ -225,18 +229,14 @@ assert version == TAL_VERSION def do_mode(self, mode): - assert mode in ["html", "xml"] + assert mode in ("html", "xml") self.html = (mode == "html") def do_setPosition(self, position): self.position = position def do_startEndTag(self, name, attrList): - if self.html and string.lower(name) not in EMPTY_HTML_TAGS: - self.do_startTag(name, attrList) - self.do_endTag(name) - else: - self.startTagCommon(name, attrList, self.endsep) + self.startTagCommon(name, attrList, self.endsep) def do_startTag(self, name, attrList): self.startTagCommon(name, attrList, ">") @@ -251,6 +251,8 @@ name, value = item[:2] if len(item) > 2: action = item[2] + if not self.showtal and action in ("tal", "metal", "xmlns"): + continue if action == "replace" and len(item) > 3 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: ok = self.engine.evaluateBoolean(item[3]) @@ -260,7 +262,9 @@ value = None else: value = self.engine.evaluateText(item[3]) - elif (action == "macroHack" and self.currentMacro and + if value is None: + continue + elif (action == "metal" and self.currentMacro and name[-13:] == ":define-macro" and self.metal): name = name[:-13] + ":use-macro" value = self.currentMacro --- Updated File TALParser.py in package Packages/TAL -- --- TALParser.py 2001/03/16 17:24:47 1.12 +++ TALParser.py 2001/04/07 19:25:03 1.13 @@ -144,10 +144,10 @@ item = self.fixname(key), value if key[:nmetal] == metalprefix: metaldict[key[nmetal:]] = value - if key[nmetal:] == "define-macro": - item = item + ("macroHack",) + item = item + ("metal",) elif key[:ntal] == talprefix: taldict[key[ntal:]] = value + item = item + ("tal",) fixedattrlist.append(item) return fixedattrlist, taldict, metaldict @@ -155,9 +155,14 @@ newlist = [] for prefix, uri in self.nsNew: if prefix: - newlist.append(("xmlns:" + prefix, uri)) + key = "xmlns:" + prefix else: - newlist.append(("xmlns", uri)) + key = "xmlns" + if uri in (ZOPE_METAL_NS, ZOPE_TAL_NS): + item = (key, uri, "xmlns") + else: + item = (key, uri) + newlist.append(item) self.nsNew = [] return newlist --- Updated File driver.py in package Packages/TAL -- --- driver.py 2001/03/27 17:16:07 1.19 +++ driver.py 2001/04/07 19:25:03 1.20 @@ -109,16 +109,18 @@ macros = 0 mode = None showcode = 0 + showtal = -1 try: - opts, args = getopt.getopt(sys.argv[1:], "hxmns") + opts, args = getopt.getopt(sys.argv[1:], "hxmnst") except getopt.error, msg: sys.stderr.write("\n%s\n" % str(msg)) sys.stderr.write( - "usage: driver.py [-h|-x] [-m] [-n] [s] [file]\n") + "usage: driver.py [-h|-x] [-m] [-n] [-s] [-t] [file]\n") sys.stderr.write("-h/-x -- HTML/XML input (default auto)\n") sys.stderr.write("-m -- macro expansion only\n") sys.stderr.write("-n -- turn off the Python 1.5.2 test\n") sys.stderr.write("-s -- print intermediate code\n") + sys.stderr.write("-t -- leave tal/metal attributes in output\n") sys.exit(2) for o, a in opts: if o == '-h': @@ -131,6 +133,8 @@ mode = "xml" if o == '-s': showcode = 1 + if o == '-t': + showtal = 1 if not versionTest: if sys.version[:5] != "1.5.2": sys.stderr.write( @@ -142,14 +146,15 @@ file = FILE it = compilefile(file, mode) if showcode: showit(it) - else: interpretit(it, tal=(not macros)) + else: interpretit(it, tal=(not macros), showtal=showtal) -def interpretit(it, engine=None, stream=None, tal=1): +def interpretit(it, engine=None, stream=None, tal=1, showtal=-1): from TALInterpreter import TALInterpreter program, macros = it if engine is None: engine = DummyEngine(macros) - TALInterpreter(program, macros, engine, stream, wrap=0, tal=tal)() + TALInterpreter(program, macros, engine, stream, wrap=0, + tal=tal, showtal=showtal)() def compilefile(file, mode=None): assert mode in ("html", "xml", None) From guido@digicool.com Sat Apr 7 20:26:11 2001 From: guido@digicool.com (guido@digicool.com) Date: Sat, 7 Apr 2001 15:26:11 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test01.html:1.2 test01.xml:1.2 test03.html:1.2 test03.xml:1.2 test04.html:1.2 test04.xml:1.2 test05.html:1.2 test05.xml:1.2 test06.html:1.3 test06.xml:1.3 test07.html:1.2 test07.xml:1.2 test08.html:1.3 test08.xml:1.3 test10.html:1.3 test11.html:1.2 test11.xml:1.2 test12.html:1.2 Message-ID: <20010407192611.CC19B51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test/output In directory korak:/tmp/cvs-serv6622/output Modified Files: test01.html test01.xml test03.html test03.xml test04.html test04.xml test05.html test05.xml test06.html test06.xml test07.html test07.xml test08.html test08.xml test10.html test11.html test11.xml test12.html Log Message: Update the test suite output, now that TAL and METAL attributes are no longer generated. Also fix the test for . --- Updated File test01.html in package Packages/TAL -- --- test01.html 2001/03/27 16:39:00 1.1 +++ test01.html 2001/04/07 19:26:08 1.2 @@ -6,16 +6,12 @@ dadada - + -

This -Is -The -Replaced Title

@@ -23,17 +19,17 @@ - here/id + here/id -

5

+

5

-

+

honda

-

+

subaru

-

+

acura

@@ -42,31 +38,31 @@
    - -
  • honda
  • + +
  • honda
  • - -
  • subaru
  • + +
  • subaru
  • - -
  • acura
  • + +
  • acura
- python - python + python + python - + - - + +  

Header Level 3

-  

Header Level 3

+  

Header Level 3

--- Updated File test01.xml in package Packages/TAL -- --- test01.xml 2001/03/27 16:39:00 1.1 +++ test01.xml 2001/04/07 19:26:08 1.2 @@ -6,26 +6,26 @@ dadada - + -

This Is The Replaced Title

+

This Is The Replaced Title

 &HarryPotter; - here/id + here/id -

5

+

5

-

+

honda

-

+

subaru

-

+

acura

@@ -34,31 +34,31 @@
    - -
  • honda
  • + +
  • honda
  • - -
  • subaru
  • + +
  • subaru
  • - -
  • acura
  • + +
  • acura
- python - python + python + python - + - - + +  

Header Level 3

-  

Header Level 3

+  

Header Level 3

--- Updated File test03.html in package Packages/TAL -- --- test03.html 2001/03/27 16:39:00 1.1 +++ test03.html 2001/04/07 19:26:08 1.2 @@ -1,10 +1,10 @@ -

- - hello brave new world - - goodbye cruel world +

+ + hello brave new world + + goodbye cruel world - hello brave new world + hello brave new world

--- Updated File test03.xml in package Packages/TAL -- --- test03.xml 2001/03/27 16:39:00 1.1 +++ test03.xml 2001/04/07 19:26:08 1.2 @@ -1,10 +1,10 @@ -

- - hello brave new world - - goodbye cruel world +

+ + hello brave new world + + goodbye cruel world - hello brave new world + hello brave new world

--- Updated File test04.html in package Packages/TAL -- --- test04.html 2001/03/27 16:39:00 1.1 +++ test04.html 2001/04/07 19:26:08 1.2 @@ -1,40 +1,40 @@ - + -
    +
    - + -
      -
    • +
        +
      • 0 hello world
      • -
      • +
      • 1 hello world
      - + -
        -
      • +
          +
        • 0 goodbye cruel world
        • -
        • +
        • 1 goodbye cruel world
        -

        define-slot

        +

        define-slot

        -

        fill-slot

        +

        fill-slot

        --- Updated File test04.xml in package Packages/TAL -- --- test04.xml 2001/03/27 16:39:00 1.1 +++ test04.xml 2001/04/07 19:26:08 1.2 @@ -1,40 +1,40 @@ - + -
          +
          - + -
            -
          • +
              +
            • 0 hello world
            • -
            • +
            • 1 hello world
            - + -
              -
            • +
                +
              • 0 goodbye cruel world
              • -
              • +
              • 1 goodbye cruel world
              -

              define-slot

              +

              define-slot

              -

              fill-slot

              +

              fill-slot

              --- Updated File test05.html in package Packages/TAL -- --- test05.html 2001/03/27 16:39:00 1.1 +++ test05.html 2001/04/07 19:26:08 1.2 @@ -1,7 +1,7 @@ - +

              This is the body of test5

              --- Updated File test05.xml in package Packages/TAL -- --- test05.xml 2001/03/27 16:39:00 1.1 +++ test05.xml 2001/04/07 19:26:08 1.2 @@ -1,7 +1,7 @@ - +

              This is the body of test5

              --- Updated File test06.html in package Packages/TAL -- --- test06.html 2001/03/27 16:42:36 1.2 +++ test06.html 2001/04/07 19:26:08 1.3 @@ -1,6 +1,6 @@ - +

              This is the body of test5

              --- Updated File test06.xml in package Packages/TAL -- --- test06.xml 2001/03/27 16:42:36 1.2 +++ test06.xml 2001/04/07 19:26:08 1.3 @@ -1,6 +1,6 @@ - +

              This is the body of test5

              --- Updated File test07.html in package Packages/TAL -- --- test07.html 2001/03/27 16:39:00 1.1 +++ test07.html 2001/04/07 19:26:08 1.2 @@ -1,5 +1,5 @@ - +
              @@ -7,6 +7,6 @@ - +
              Top Left
              Bottom leftBottom RightBottom Right
              --- Updated File test07.xml in package Packages/TAL -- --- test07.xml 2001/03/27 16:39:00 1.1 +++ test07.xml 2001/04/07 19:26:08 1.2 @@ -1,5 +1,5 @@ - +
              @@ -7,6 +7,6 @@ - +
              Top Left
              Bottom leftBottom RightBottom Right
              --- Updated File test08.html in package Packages/TAL -- --- test08.html 2001/03/27 16:42:36 1.2 +++ test08.html 2001/04/07 19:26:08 1.3 @@ -1,5 +1,5 @@ - +
              @@ -7,7 +7,7 @@ -
              Top Left
              Bottom left +

              Some headline

              This is the real contents of the bottom right slot.

              It is supposed to contain a lot of text. Blah, blah, blab. --- Updated File test08.xml in package Packages/TAL -- --- test08.xml 2001/03/27 16:42:36 1.2 +++ test08.xml 2001/04/07 19:26:08 1.3 @@ -1,5 +1,5 @@ - +
              @@ -7,7 +7,7 @@ -
              Top Left
              Bottom left +

              Some headline

              This is the real contents of the bottom right slot.

              It is supposed to contain a lot of text. Blah, blah, blab. --- Updated File test10.html in package Packages/TAL -- --- test10.html 2001/03/27 17:18:36 1.2 +++ test10.html 2001/04/07 19:26:08 1.3 @@ -1,5 +1,5 @@ - +
              @@ -7,7 +7,7 @@ - ???? ZPT makes it infinitely easier to do Zope stuff in Dreamweaver over DTML, but designers still have to keep a very watchful eye on the source window. We make heavy use of CSS to minimise the tag count (yes, it can be done, with a good CSS compatibility guide like http://www.blooberry.com/indexdot/css/). And we have a lot of predefined library items with all the appropriate ZPT attributes on them, just in case the designers lose something important :) Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From bitz@bitdance.com Mon Apr 9 00:28:43 2001 From: bitz@bitdance.com (R. David Murray ) Date: Sun, 8 Apr 2001 19:28:43 -0400 (EDT) Subject: [ZPT] My First Post In-Reply-To: <3AD0EDD1.D2DBC493@bizarsoftware.com.au> Message-ID: On Mon, 9 Apr 2001 richard@bizarsoftware.com.au wrote: > OK, so why is one a noun and one a verb? That part of my post was all about > consistency, or the lack thereof :) > > And why does 'attributes', as a noun, still have to be plural? Well, this is kind of silly, but... 'define' is normally a verb in English. It probably doesn't get used as a noun by anybody other than programmers, and even programmers use it as a verb most of the time. That tag is 'defining' things, thus I hear it as a verb, even though the noun usage would also make semantic sense in this context. If you want the noun, you should really be using 'definitions'. 'attributes' can only be a noun. To make it parallel with define-as-a-verb, you'd have to make it 'replace-attributes' or something. Unweildy. At least having 'attributes' be plural keeps it number-parallel with define, which is the plural form of the verb...although it's really the imperative form as it is used here . --RDM From bitz@bitdance.com Mon Apr 9 00:32:47 2001 From: bitz@bitdance.com (R. David Murray ) Date: Sun, 8 Apr 2001 19:32:47 -0400 (EDT) Subject: [ZPT] My First Post In-Reply-To: Message-ID: On Sun, 8 Apr 2001, R. David Murray wrote: > 'attributes' can only be a noun. In this semantic context :) From richard@bizarsoftware.com.au Mon Apr 9 00:50:35 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 09:50:35 +1000 Subject: [ZPT] Debugging helpers Message-ID: <3AD0F94B.63675D0D@bizarsoftware.com.au> I've made a change to Expressions.py and PageTemplate.py to make debugging a lot easier. Sorry I can't provide patches - I'm a little out of sync with the CVS at the moment. In PythonExpr.__call__, I have: # Execute the function in a new security context. template = econtext.contexts['template'] security = getSecurityManager() security.addContext(template) try: if Globals.DevelopmentMode: __traceback_info__ = self.expr return f() finally: security.removeContext(template) the __traceback_info__ is invaluable in figuring out what what's gone wrong. Having some way to identify the actual line number of the expression would be a real bonus. In PageTemplate.pr_render, I have: def pt_render(self, source=0, extra_context={}): """Render this Page Template""" if self._v_errors: return self.pt_diagnostic() output = StringIO() c = self.pt_getContext() c.update(extra_context) #__traceback_info__ = c if Globals.DevelopmentMode: __traceback_info__ = pprint.pformat(c) again, the traceback info is handy to have, but it's annoying when not pretty-formatted. Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Mon Apr 9 01:50:38 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 10:50:38 +1000 Subject: [ZPT] Debugging helpers References: <3AD0F94B.63675D0D@bizarsoftware.com.au> Message-ID: <3AD1075E.7641A51B@bizarsoftware.com.au> richard@bizarsoftware.com.au wrote: > In PageTemplate.pr_render, I have: > > def pt_render(self, source=0, extra_context={}): > """Render this Page Template""" > if self._v_errors: > return self.pt_diagnostic() > output = StringIO() > c = self.pt_getContext() > c.update(extra_context) > #__traceback_info__ = c > if Globals.DevelopmentMode: > __traceback_info__ = pprint.pformat(c) > > again, the traceback info is handy to have, but it's annoying when not > pretty-formatted. Oh, and by default, we always comment out the __repr__=__str__ line in HTTPRequest and BaseRequest. That also reduces the verbosity of exceptions (and we have no reason to want __repr__ == __str__). Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Mon Apr 9 08:24:30 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 17:24:30 +1000 Subject: [ZPT] Debugging helpers References: <3AD0F94B.63675D0D@bizarsoftware.com.au> Message-ID: <3AD163AE.B8D0515@bizarsoftware.com.au> richard@bizarsoftware.com.au wrote: > I've made a change to Expressions.py and PageTemplate.py to make debugging > a lot easier. Sorry I can't provide patches - I'm a little out of sync with > the CVS at the moment. I've just added another "__traceback_info__ = expr" to TALInterpreter.do_insertStructure to help find what particular call raised the "invalid '<' construct: '<-', at line 30, column 46" errors ;) Damn that __traceback_info__ is useful! Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Mon Apr 9 09:21:50 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 18:21:50 +1000 Subject: [ZPT] playing with stylesheets in ZPT? Message-ID: <3AD1711E.74C7DD75@bizarsoftware.com.au> Let's say that we have an object tree where every page in the tree has the following in it: The images dictionary is an acquired attribute. If we're to avoid reloading the background image for every page down the acuisition tree, then we need to modify that 'images/main_back.gif' url so it is the same on each page. We can do it for tags by preprocessing the page and inserting tal:attributes attributes to do the job. Not so for the contents of the style tag. In the Bad Ol Days of DTML, I just had a dtml statement in there, like url(/main_back.gif) which worked just fine and dandy... ;) Now, remembering that this CSS may be entered by any random Web Designer and that it may contain any number of other statements, possibly with a bunch of other url(images/blah.gif) in them... It's currently impossible as far as I can tell, to have ZPT do what I used to do in DTML. What _would_ make it possible, would be to be able to, say, - set for your designers to fiddle with...?? perhaps i misunderstood your problem, but i am currently of the opinion that dynamicism inside style or script elements would be simpler in dtml/python , and just fetching the entire block into your template with tal:replace or tal:content... Geir Bækholt geirh@funcom.com >Let's say that we have an object tree where every page in the tree has the >following in it: > > > >The images dictionary is an acquired attribute. If we're to avoid reloading >the background image for every page down the acuisition tree, then we need >to modify that 'images/main_back.gif' url so it is the same on each page. >We can do it for tags by preprocessing the page and inserting >tal:attributes attributes to do the job. Not so for the contents of the >style tag. > >In the Bad Ol Days of DTML, I just had a dtml statement in there, like > url(/main_back.gif) >which worked just fine and dandy... ;) > >Now, remembering that this CSS may be entered by any random Web Designer >and that it may contain any number of other statements, possibly with a >bunch of other url(images/blah.gif) in them... > >It's currently impossible as far as I can tell, to have ZPT do what I used >to do in DTML. > >What _would_ make it possible, would be to be able to, say, > > > > The images dictionary is an acquired attribute. If we're to avoid reloading > the background image for every page down the acuisition tree, then we need > to modify that 'images/main_back.gif' url so it is the same on each page. > We can do it for tags by preprocessing the page and inserting > tal:attributes attributes to do the job. Not so for the contents of the > style tag. > > In the Bad Ol Days of DTML, I just had a dtml statement in there, like > url(/main_back.gif) > which worked just fine and dandy... ;) > > Now, remembering that this CSS may be entered by any random Web Designer > and that it may contain any number of other statements, possibly with a > bunch of other url(images/blah.gif) in them... > > It's currently impossible as far as I can tell, to have ZPT do what I used > to do in DTML. > > What _would_ make it possible, would be to be able to, say, > > \n' % ( getattr(context, sheet)) else: html = '' % ( context.portal_url(), sheet) return html return '' The above code is somewhat CMF specific; it assumes that an object 'stylesheet_properties' defines the name of the stylesheet. You can fold the 'if hasattr', and name your stylesheet directly. For example, if your stylesheet is called 'site_style.css', you could use: import string ag = context.REQUEST.get('HTTP_USER_AGENT', '') sheet = getattr(context, 'site_style.css') if ag[:9] == 'Mozilla/4' and string.find(ag, 'MSIE') < 0: # For Navigator 4.x, inline the stylesheet. html = '\n' % sheet else: html = '' % ( sheet.absolute_url()) return html The idea is that this code generates the correct tag for stylesheet inclusion. You can then manipulate your stylesheet as an external sheet (stored in a DTMLMethod perhaps) with DreamWeaver or GoLive with the usual tools. You only have to make sure that the ZPT tag above has a href attribute that points to the correct location (which is what designers should put in anyway). You can then use classic DTML on your stylesheet to make sure that images are referenced using absolute URLs. -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ --------------------------------------------- From guido@digicool.com Mon Apr 9 15:11:06 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 10:11:06 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmlparser.py:1.13 Message-ID: <20010409141106.3FAF951014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv11951 Modified Files: test_htmlparser.py Log Message: Make the cdata test more stringent, testing for a bug in the current code. --- Updated File test_htmlparser.py in package Packages/TAL -- --- test_htmlparser.py 2001/04/06 22:19:14 1.12 +++ test_htmlparser.py 2001/04/09 14:11:05 1.13 @@ -243,6 +243,7 @@ def check_cdata_content(self): s = """""" + s = list(s) self._run_check(s, [ ("starttag", "script", []), ("data", " ¬-an-entity-ref; "), From guido@digicool.com Mon Apr 9 15:15:20 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 10:15:20 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLParser.py:1.14 Message-ID: <20010409141520.A118C51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv14537 Modified Files: HTMLParser.py Log Message: The cdata handling code for """ - s = list(s) self._run_check(s, [ ("starttag", "script", []), ("data", " ¬-an-entity-ref; "), From fred@digicool.com Mon Apr 9 18:23:51 2001 From: fred@digicool.com (fred@digicool.com) Date: Mon, 9 Apr 2001 13:23:51 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLParser.py:1.15 Message-ID: <20010409172351.BDC4451014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv31141 Modified Files: HTMLParser.py Log Message: Fix two buffer boundary issues; this restores this to passing the test suite without any large restructuring. Guido & I will be looking at how this is structured later; buffer boundary checks will make this nearly unmaintainable if we can't bring about a better structure to the code. (Better tests would also be nice!) --- Updated File HTMLParser.py in package Packages/TAL -- --- HTMLParser.py 2001/04/09 14:15:19 1.14 +++ HTMLParser.py 2001/04/09 17:23:50 1.15 @@ -243,6 +243,10 @@ rawdata = self.rawdata j = i + 2 assert rawdata[i:j] == "' n = len(rawdata) while j < n: @@ -340,14 +344,24 @@ next = rawdata[j:j+1] if next == ">": return j + 1 - if rawdata[j:j+2] == "/>": - return j + 2 + if next == "/": + s = rawdata[j:j+2] + if s == "/>": + return j + 2 + if s == "/": + # buffer boundary + return -1 + # else bogus input + self.updatepos(i, j + 1) + raise HTMLParseError("malformed empty start tag", + self.getpos()) if next == "": # end of input return -1 - if next in ("abcdefghijklmnopqrstuvwxyz=" + if next in ("abcdefghijklmnopqrstuvwxyz=/" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): - # end of input in or before attribute value + # end of input in or before attribute value, or we have the + # '/' from a '/>' ending return -1 self.updatepos(i, j) raise HTMLParseError("malformed start tag", self.getpos()) From evan@digicool.com Mon Apr 9 22:13:53 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 17:13:53 -0400 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> Message-ID: <029101c0c139$fb17ee00$01000001@yosemite> From: "Guido van Rossum" > > "if::" could also be "optional:", or whatever. > > OK, good. Now I understand. Should we do this for 1.1? (It's not > hard!) From: > Is there some reason why we couldn't just make use of 'exists'? It has no > real use in the content/replace TAL operations. Make doNothing a false > value. Or is that overloading the 'exists' keyword too much? And what's the > behaviour of the test in tal:replace? I think it'd be the same as > replace/content - the tag stays as is, with no further processing. I've put a proposal in the Project Wiki under DiscussTALES based on this idea, using 'exists'. I'd like to have it there for at least a day or two before acting on it. Please comment, especially on implementation details like the singleton object used to signal non-existence. Cheers, Evan @ digicool From evan@digicool.com Mon Apr 9 22:23:26 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 17:23:26 -0400 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> Message-ID: <029901c0c13b$50aa8e80$01000001@yosemite> From: "Guido van Rossum" > I've checked in the changes to suppress output of TAL, METAL and > relevant XMLNS attributes. These are suppressed by default when > 'tal=1' is passed to the TALInterpreter() constructor. You can force > showing them by passing this constructor 'showtal=1', and force hiding > them (not sure what good that is :-) with 'showtal=0'. Thanks, I've changed the ZPT tests to reflect this behaviour. > what to do about old programs -- I could either provide a function > that checks whether a program is still valid, or I could try to make > the TALInterpreter support older versions (with reason). I would expect to check whether a program is valid, then throw it out and recompile if it isn't. > Do you want the simplified handling of structure replace/content in 1.0.1? Jim pointed out that the attribute suppression is a fairly major new feature, so I plan to go straight to 1.1 tomorrow. As part of this, I went ahead and made Page Templates pass strictinsert=0. Cheers, Evan @ digicool From gotcha@swing.be Mon Apr 9 22:58:48 2001 From: gotcha@swing.be (Godefroid Chapelle) Date: Mon, 09 Apr 2001 23:58:48 +0200 Subject: [ZPT] problems with   and
              Message-ID: <3AD23098.753BCB0D@swing.be> Sorry if this question has already been asked and answered... Are there anyway to preserve the browser complaint XHTML
              instead of receiving
              which is not recognized... Further, are ther anyway to escape the transformation of & to & so that I can use   as a tal replace argument ? Thanks -- Godefroid Chapelle BubbleNet sprl rue Victor Horta, 30 1348 Louvain-la-Neuve Belgium Tel 010 457490 Mob 0477 363942 TVA 467 093 008 RC Niv 49849 From guido@digicool.com Tue Apr 10 00:19:10 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:19:10 -0500 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 In-Reply-To: Your message of "Mon, 09 Apr 2001 17:23:26 -0400." <029901c0c13b$50aa8e80$01000001@yosemite> References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> Message-ID: <200104092319.SAA02830@cj20424-a.reston1.va.home.com> > > what to do about old programs -- I could either provide a function > > that checks whether a program is still valid, or I could try to make > > the TALInterpreter support older versions (with reason). > > I would expect to check whether a program is valid, then throw it out and > recompile if it isn't. Do you want me to provide a function that checks whether a program is still valid? I propose the following API: import TALDefs TALDefs.isValidProgram((program, macros)) -> Boolean Note that isValidProgram() takes a single argument that's a tuple of (program, macros) -- that way you can pass it the cached output from a previous compilation without having to know its structure. This wouldn't be a surefire test, e.g. if you gave it a hand-constructed tuple you might have something that passed the test but would raise an exception when passed to TALInterpreter() -- but it would guarantee to give the correct result for anything that was ever returned by a TAL compiler. If you don't like this, please suggest an API... > > Do you want the simplified handling of structure replace/content in 1.0.1? > > Jim pointed out that the attribute suppression is a fairly major new > feature, so I plan to go straight to 1.1 tomorrow. As part of this, I went > ahead and made Page Templates pass strictinsert=0. OK. Good! --Guido van Rossum (home page: http://www.python.org/~guido/) From fred@digicool.com Mon Apr 9 23:21:52 2001 From: fred@digicool.com (fred@digicool.com) Date: Mon, 9 Apr 2001 18:21:52 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_xmlparser.py:1.2 Message-ID: <20010409222152.C8AC851014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv14504 Modified Files: test_xmlparser.py Log Message: XMLParserTestCase.check_bad_nesting(): Use self.fail() instead of naming AssertionError directly; how PyUnit deals with the error is it's problem, not ours. ;-) --- Updated File test_xmlparser.py in package Packages/TAL -- --- test_xmlparser.py 2001/03/26 19:21:07 1.1 +++ test_xmlparser.py 2001/04/09 22:21:51 1.2 @@ -151,7 +151,7 @@ self.assert_(e.lineno == 1, "did not receive correct position information") else: - raise AssertionError("expected parse error: bad nesting") + self.fail("expected parse error: bad nesting") def check_attr_syntax(self): output = [ From guido@digicool.com Tue Apr 10 00:36:28 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:36:28 -0500 Subject: [ZPT] problems with   and
              In-Reply-To: Your message of "Mon, 09 Apr 2001 23:58:48 +0200." <3AD23098.753BCB0D@swing.be> References: <3AD23098.753BCB0D@swing.be> Message-ID: <200104092336.SAA03135@cj20424-a.reston1.va.home.com> > Sorry if this question has already been asked and answered... > > Are there anyway to preserve the browser complaint XHTML
              instead > of receiving
              which is not recognized... Oops, I think not. I'll have to fix this, because this used to be a requirement. Note that you can write
              , but then of course it won't be valid XHTML. > Further, are ther anyway to escape the transformation of & to & so > that I can use   as a tal replace argument ? Yes, use &nbsp;. Ugly but works. --Guido van Rossum (home page: http://www.python.org/~guido/) From evan@digicool.com Mon Apr 9 23:45:36 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 18:45:36 -0400 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> <200104092319.SAA02830@cj20424-a.reston1.va.home.com> Message-ID: <02e701c0c146$cb57bc10$01000001@yosemite> From: "Guido van Rossum" > Do you want me to provide a function that checks whether a program is > still valid? I propose the following API: > > import TALDefs > > TALDefs.isValidProgram((program, macros)) -> Boolean > > Note that isValidProgram() takes a single argument that's a tuple of > (program, macros) -- that way you can pass it the cached output from a > previous compilation without having to know its structure. Hmm. I already pay close attention to its structure, since I expose the macros separately. Hey, I just noticed; TALInterpreter doesn't do anything with the macros argument except hold onto it, right? Also, a macro is a valid program in its own right. So really, this should just accept a single program. The macro program will get tested for validity when a use-macro tries to retreive it. > This wouldn't be a surefire test, e.g. if you gave it a > hand-constructed tuple you might have something that passed the test In that case, the name seems to promise too much. How about TALDefs.isCurrentVersion(program)? Cheers, Evan @ digicool From evan@digicool.com Mon Apr 9 23:47:36 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 18:47:36 -0400 Subject: [ZPT] problems with   and
              References: <3AD23098.753BCB0D@swing.be> <200104092336.SAA03135@cj20424-a.reston1.va.home.com> Message-ID: <02f101c0c147$12aab4f0$01000001@yosemite> From: "Guido van Rossum" > > Are there anyway to preserve the browser complaint XHTML
              instead > > of receiving
              which is not recognized... > > Oops, I think not. I'll have to fix this, because this used to be a > requirement. I don't understand. Inserting the space before the slash contradicts a requirement? Cheers, Evan @ digicool From guido@digicool.com Mon Apr 9 23:51:35 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:51:35 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALInterpreter.py:1.34 Message-ID: <20010409225135.6293E51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv32467 Modified Files: TALInterpreter.py Log Message: Now that self.html is set and cleared by do_mode(), also set self.endsep to the proper value there. --- Updated File TALInterpreter.py in package Packages/TAL -- --- TALInterpreter.py 2001/04/09 15:27:29 1.33 +++ TALInterpreter.py 2001/04/09 22:51:34 1.34 @@ -167,6 +167,7 @@ self.showtal = showtal self.strictinsert = strictinsert self.html = 0 + self.endsep = "/>" self.slots = {} self.currentMacro = None self.position = None, None # (lineno, offset) @@ -192,10 +193,6 @@ def __call__(self): assert self.level == 0 assert self.scopeLevel == 0 - if self.html: - self.endsep = " />" - else: - self.endsep = "/>" self.interpret(self.program) assert self.level == 0 assert self.scopeLevel == 0 @@ -233,6 +230,10 @@ def do_mode(self, mode): assert mode in ("html", "xml") self.html = (mode == "html") + if self.html: + self.endsep = " />" + else: + self.endsep = "/>" def do_setPosition(self, position): self.position = position From guido@digicool.com Mon Apr 9 23:53:16 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:53:16 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALGenerator.py:1.31 Message-ID: <20010409225316.33BA051014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv1024 Modified Files: TALGenerator.py Log Message: When optimizing startEndTag, use " />" as the end separator when generating HTML, and "/>" for XML, instead of always using "/>". This is necessary for proper XHTML generation. --- Updated File TALGenerator.py in package Packages/TAL -- --- TALGenerator.py 2001/04/06 00:59:45 1.30 +++ TALGenerator.py 2001/04/09 22:53:15 1.31 @@ -118,6 +118,10 @@ output = [] collect = [] rawseen = cursor = 0 + if self.xml: + endsep = "/>" + else: + endsep = " />" for cursor in xrange(len(program)+1): try: item = program[cursor] @@ -133,7 +137,7 @@ if self.optimizeStartTag(collect, item[1], item[2], ">"): continue if item[0] == "startEndTag": - if self.optimizeStartTag(collect, item[1], item[2], "/>"): + if self.optimizeStartTag(collect, item[1], item[2], endsep): continue text = string.join(collect, "") if text: From guido@digicool.com Mon Apr 9 23:53:54 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:53:54 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test01.html:1.3 test02.html:1.2 test04.html:1.3 test12.html:1.3 Message-ID: <20010409225354.5463C51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test/output In directory korak:/tmp/cvs-serv1539 Modified Files: test01.html test02.html test04.html test12.html Log Message: Update HTML test output for space before /> --- Updated File test01.html in package Packages/TAL -- --- test01.html 2001/04/07 19:26:08 1.2 +++ test01.html 2001/04/09 22:53:53 1.3 @@ -58,8 +58,8 @@ - - + +  

              Header Level 3

               

              Header Level 3

              --- Updated File test02.html in package Packages/TAL -- --- test02.html 2001/03/27 16:39:00 1.1 +++ test02.html 2001/04/09 22:53:53 1.2 @@ -37,12 +37,12 @@ CANADA - + ATTN: PAULINE DEGRASSI - - - - + + + + --- Updated File test04.html in package Packages/TAL -- --- test04.html 2001/04/07 19:26:08 1.2 +++ test04.html 2001/04/09 22:53:53 1.3 @@ -6,7 +6,7 @@
              - +
              • @@ -19,7 +19,7 @@
              - +
              • --- Updated File test12.html in package Packages/TAL -- --- test12.html 2001/04/07 19:26:08 1.2 +++ test12.html 2001/04/09 22:53:53 1.3 @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - + From guido@digicool.com Tue Apr 10 00:57:37 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:57:37 -0500 Subject: [ZPT] problems with   and
                In-Reply-To: Your message of "Mon, 09 Apr 2001 23:58:48 +0200." <3AD23098.753BCB0D@swing.be> References: <3AD23098.753BCB0D@swing.be> Message-ID: <200104092357.SAA03324@cj20424-a.reston1.va.home.com> > Are there anyway to preserve the browser complaint XHTML
                instead > of receiving
                which is not recognized... This is now fixed in the CVS tree and will be incorporated in the 1.1 release tomorrow. --Guido van Rossum (home page: http://www.python.org/~guido/) From guido@digicool.com Tue Apr 10 01:04:21 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 19:04:21 -0500 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 In-Reply-To: Your message of "Mon, 09 Apr 2001 18:45:36 -0400." <02e701c0c146$cb57bc10$01000001@yosemite> References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> <200104092319.SAA02830@cj20424-a.reston1.va.home.com> <02e701c0c146$cb57bc10$01000001@yosemite> Message-ID: <200104100004.TAA03404@cj20424-a.reston1.va.home.com> > From: "Guido van Rossum" > > Do you want me to provide a function that checks whether a program is > > still valid? I propose the following API: > > > > import TALDefs > > > > TALDefs.isValidProgram((program, macros)) -> Boolean > > > > Note that isValidProgram() takes a single argument that's a tuple of > > (program, macros) -- that way you can pass it the cached output from a > > previous compilation without having to know its structure. [Evan] > Hmm. I already pay close attention to its structure, since I expose the > macros separately. Hey, I just noticed; TALInterpreter doesn't do anything > with the macros argument except hold onto it, right? Also, a macro is a > valid program in its own right. So really, this should just accept a single > program. The macro program will get tested for validity when a use-macro > tries to retreive it. Hm, but macros don't have a version number of their own. Should they? > > This wouldn't be a surefire test, e.g. if you gave it a > > hand-constructed tuple you might have something that passed the test > > In that case, the name seems to promise too much. How about > TALDefs.isCurrentVersion(program)? OK. I just realized: there's an issue with mixing XML macros and HTML code or vice versa: the macros are optimized/precompiled for the mode used to compile them. To fix this I would probably need another inquiry function that returns the mode ("xml" or "html") from a program, *and* add version *and* mode instructions to all macros. --Guido van Rossum (home page: http://www.python.org/~guido/) From richard@bizarsoftware.com.au Tue Apr 10 00:42:26 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Tue, 10 Apr 2001 09:42:26 +1000 Subject: [ZPT] playing with stylesheets in ZPT? References: <3AD1711E.74C7DD75@bizarsoftware.com.au> <20010409112037.A31388@zopatista.com> Message-ID: <3AD248E2.E528D248@bizarsoftware.com.au> Martijn Pieters wrote: > On Mon, Apr 09, 2001 at 06:21:50PM +1000, richard@bizarsoftware.com.au wrote: > > Let's say that we have an object tree where every page in the tree has the > > following in it: > > > > > > Hmm.. I'd make the stylesheet a Python Script or something.. Can't - the stylesheet is created in the page by a web designer. We want them to be able to create the page with the minimum of fuss. The entire ZPT layout must be viewable and editable in Dreamweaver, both before it's "uploaded" to the Product which is rendering it and afterwards. I can't just remove the stylesheet information from the page and place it elsewhere. We can't move the CSS out to a linked stylesheet, because Netscape is really picky about where you put background image declarations, and a linked stylesheet doesn't cut its mustard. Ultimately this is all Netscape 4.7's fault :) > Or you could > go the CMF way and make the CSS Stylesheet external but include it in the > case of Netscape 4 clients. I converted that to ZPT for the Internet World > demo and that worked great. As a rule, we never, ever, use linked stylesheets. Even IE gets it wrong sometimes. > I used the following code to include the stylesheet (which keeps working > in Dreamweaver and GoLive if you fill in a correct href attribute on the > tag): > > tal:replace="structure here/css_inline_or_link" /> If the stylesheet is linked in, this is fine. But if the stylesheet is in the page, I can't do anything in ZPT at the moment to this end. > [code snipped] We have a very similar thing for the ZPT - the page is parsed at cook time and tal:attributes statements are inserted into and tags to make them do the "correct" thing at render time. I just need something I can do for the _content_ of the The images dictionary is an acquired attribute. If we're to avoid reloading the background image for every page down the acuisition tree, then we need to modify that 'images/main_back.gif' url so it is the same on each page. We can do it for tags by preprocessing the page and inserting tal:attributes attributes to do the job. Not so for the contents of the style tag. In the Bad Ol Days of DTML, I just had a dtml statement in there, like url(/main_back.gif) which worked just fine and dandy... ;) Now, remembering that this CSS may be entered by any random Web Designer and that it may contain any number of other statements, possibly with a bunch of other url(images/blah.gif) in them... It's currently impossible as far as I can tell, to have ZPT do what I used to do in DTML. What _would_ make it possible, would be to be able to, say, - set for your designers to fiddle with...?? perhaps i misunderstood your problem, but i am currently of the opinion that dynamicism inside style or script elements would be simpler in dtml/python , and just fetching the entire block into your template with tal:replace or tal:content... Geir Bækholt geirh@funcom.com >Let's say that we have an object tree where every page in the tree has the >following in it: > > > >The images dictionary is an acquired attribute. If we're to avoid reloading >the background image for every page down the acuisition tree, then we need >to modify that 'images/main_back.gif' url so it is the same on each page. >We can do it for tags by preprocessing the page and inserting >tal:attributes attributes to do the job. Not so for the contents of the >style tag. > >In the Bad Ol Days of DTML, I just had a dtml statement in there, like > url(/main_back.gif) >which worked just fine and dandy... ;) > >Now, remembering that this CSS may be entered by any random Web Designer >and that it may contain any number of other statements, possibly with a >bunch of other url(images/blah.gif) in them... > >It's currently impossible as far as I can tell, to have ZPT do what I used >to do in DTML. > >What _would_ make it possible, would be to be able to, say, > > > > The images dictionary is an acquired attribute. If we're to avoid reloading > the background image for every page down the acuisition tree, then we need > to modify that 'images/main_back.gif' url so it is the same on each page. > We can do it for tags by preprocessing the page and inserting > tal:attributes attributes to do the job. Not so for the contents of the > style tag. > > In the Bad Ol Days of DTML, I just had a dtml statement in there, like > url(/main_back.gif) > which worked just fine and dandy... ;) > > Now, remembering that this CSS may be entered by any random Web Designer > and that it may contain any number of other statements, possibly with a > bunch of other url(images/blah.gif) in them... > > It's currently impossible as far as I can tell, to have ZPT do what I used > to do in DTML. > > What _would_ make it possible, would be to be able to, say, > > \n' % ( getattr(context, sheet)) else: html = '' % ( context.portal_url(), sheet) return html return '' The above code is somewhat CMF specific; it assumes that an object 'stylesheet_properties' defines the name of the stylesheet. You can fold the 'if hasattr', and name your stylesheet directly. For example, if your stylesheet is called 'site_style.css', you could use: import string ag = context.REQUEST.get('HTTP_USER_AGENT', '') sheet = getattr(context, 'site_style.css') if ag[:9] == 'Mozilla/4' and string.find(ag, 'MSIE') < 0: # For Navigator 4.x, inline the stylesheet. html = '\n' % sheet else: html = '' % ( sheet.absolute_url()) return html The idea is that this code generates the correct tag for stylesheet inclusion. You can then manipulate your stylesheet as an external sheet (stored in a DTMLMethod perhaps) with DreamWeaver or GoLive with the usual tools. You only have to make sure that the ZPT tag above has a href attribute that points to the correct location (which is what designers should put in anyway). You can then use classic DTML on your stylesheet to make sure that images are referenced using absolute URLs. -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ --------------------------------------------- From guido@digicool.com Mon Apr 9 15:11:06 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 10:11:06 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmlparser.py:1.13 Message-ID: <20010409141106.3FAF951014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv11951 Modified Files: test_htmlparser.py Log Message: Make the cdata test more stringent, testing for a bug in the current code. --- Updated File test_htmlparser.py in package Packages/TAL -- --- test_htmlparser.py 2001/04/06 22:19:14 1.12 +++ test_htmlparser.py 2001/04/09 14:11:05 1.13 @@ -243,6 +243,7 @@ def check_cdata_content(self): s = """""" + s = list(s) self._run_check(s, [ ("starttag", "script", []), ("data", " ¬-an-entity-ref; "), From guido@digicool.com Mon Apr 9 15:15:20 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 10:15:20 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLParser.py:1.14 Message-ID: <20010409141520.A118C51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv14537 Modified Files: HTMLParser.py Log Message: The cdata handling code for """ - s = list(s) self._run_check(s, [ ("starttag", "script", []), ("data", " ¬-an-entity-ref; "), From fred@digicool.com Mon Apr 9 18:23:51 2001 From: fred@digicool.com (fred@digicool.com) Date: Mon, 9 Apr 2001 13:23:51 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - HTMLParser.py:1.15 Message-ID: <20010409172351.BDC4451014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv31141 Modified Files: HTMLParser.py Log Message: Fix two buffer boundary issues; this restores this to passing the test suite without any large restructuring. Guido & I will be looking at how this is structured later; buffer boundary checks will make this nearly unmaintainable if we can't bring about a better structure to the code. (Better tests would also be nice!) --- Updated File HTMLParser.py in package Packages/TAL -- --- HTMLParser.py 2001/04/09 14:15:19 1.14 +++ HTMLParser.py 2001/04/09 17:23:50 1.15 @@ -243,6 +243,10 @@ rawdata = self.rawdata j = i + 2 assert rawdata[i:j] == "' n = len(rawdata) while j < n: @@ -340,14 +344,24 @@ next = rawdata[j:j+1] if next == ">": return j + 1 - if rawdata[j:j+2] == "/>": - return j + 2 + if next == "/": + s = rawdata[j:j+2] + if s == "/>": + return j + 2 + if s == "/": + # buffer boundary + return -1 + # else bogus input + self.updatepos(i, j + 1) + raise HTMLParseError("malformed empty start tag", + self.getpos()) if next == "": # end of input return -1 - if next in ("abcdefghijklmnopqrstuvwxyz=" + if next in ("abcdefghijklmnopqrstuvwxyz=/" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): - # end of input in or before attribute value + # end of input in or before attribute value, or we have the + # '/' from a '/>' ending return -1 self.updatepos(i, j) raise HTMLParseError("malformed start tag", self.getpos()) From evan@digicool.com Mon Apr 9 22:13:53 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 17:13:53 -0400 Subject: [ZPT] Extending tal:condition, making metal:define References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> Message-ID: <029101c0c139$fb17ee00$01000001@yosemite> From: "Guido van Rossum" > > "if::" could also be "optional:", or whatever. > > OK, good. Now I understand. Should we do this for 1.1? (It's not > hard!) From: > Is there some reason why we couldn't just make use of 'exists'? It has no > real use in the content/replace TAL operations. Make doNothing a false > value. Or is that overloading the 'exists' keyword too much? And what's the > behaviour of the test in tal:replace? I think it'd be the same as > replace/content - the tag stays as is, with no further processing. I've put a proposal in the Project Wiki under DiscussTALES based on this idea, using 'exists'. I'd like to have it there for at least a day or two before acting on it. Please comment, especially on implementation details like the singleton object used to signal non-existence. Cheers, Evan @ digicool From evan@digicool.com Mon Apr 9 22:23:26 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 17:23:26 -0400 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> Message-ID: <029901c0c13b$50aa8e80$01000001@yosemite> From: "Guido van Rossum" > I've checked in the changes to suppress output of TAL, METAL and > relevant XMLNS attributes. These are suppressed by default when > 'tal=1' is passed to the TALInterpreter() constructor. You can force > showing them by passing this constructor 'showtal=1', and force hiding > them (not sure what good that is :-) with 'showtal=0'. Thanks, I've changed the ZPT tests to reflect this behaviour. > what to do about old programs -- I could either provide a function > that checks whether a program is still valid, or I could try to make > the TALInterpreter support older versions (with reason). I would expect to check whether a program is valid, then throw it out and recompile if it isn't. > Do you want the simplified handling of structure replace/content in 1.0.1? Jim pointed out that the attribute suppression is a fairly major new feature, so I plan to go straight to 1.1 tomorrow. As part of this, I went ahead and made Page Templates pass strictinsert=0. Cheers, Evan @ digicool From gotcha@swing.be Mon Apr 9 22:58:48 2001 From: gotcha@swing.be (Godefroid Chapelle) Date: Mon, 09 Apr 2001 23:58:48 +0200 Subject: [ZPT] problems with   and
                Message-ID: <3AD23098.753BCB0D@swing.be> Sorry if this question has already been asked and answered... Are there anyway to preserve the browser complaint XHTML
                instead of receiving
                which is not recognized... Further, are ther anyway to escape the transformation of & to & so that I can use   as a tal replace argument ? Thanks -- Godefroid Chapelle BubbleNet sprl rue Victor Horta, 30 1348 Louvain-la-Neuve Belgium Tel 010 457490 Mob 0477 363942 TVA 467 093 008 RC Niv 49849 From guido@digicool.com Tue Apr 10 00:19:10 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:19:10 -0500 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 In-Reply-To: Your message of "Mon, 09 Apr 2001 17:23:26 -0400." <029901c0c13b$50aa8e80$01000001@yosemite> References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> Message-ID: <200104092319.SAA02830@cj20424-a.reston1.va.home.com> > > what to do about old programs -- I could either provide a function > > that checks whether a program is still valid, or I could try to make > > the TALInterpreter support older versions (with reason). > > I would expect to check whether a program is valid, then throw it out and > recompile if it isn't. Do you want me to provide a function that checks whether a program is still valid? I propose the following API: import TALDefs TALDefs.isValidProgram((program, macros)) -> Boolean Note that isValidProgram() takes a single argument that's a tuple of (program, macros) -- that way you can pass it the cached output from a previous compilation without having to know its structure. This wouldn't be a surefire test, e.g. if you gave it a hand-constructed tuple you might have something that passed the test but would raise an exception when passed to TALInterpreter() -- but it would guarantee to give the correct result for anything that was ever returned by a TAL compiler. If you don't like this, please suggest an API... > > Do you want the simplified handling of structure replace/content in 1.0.1? > > Jim pointed out that the attribute suppression is a fairly major new > feature, so I plan to go straight to 1.1 tomorrow. As part of this, I went > ahead and made Page Templates pass strictinsert=0. OK. Good! --Guido van Rossum (home page: http://www.python.org/~guido/) From fred@digicool.com Mon Apr 9 23:21:52 2001 From: fred@digicool.com (fred@digicool.com) Date: Mon, 9 Apr 2001 18:21:52 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_xmlparser.py:1.2 Message-ID: <20010409222152.C8AC851014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv14504 Modified Files: test_xmlparser.py Log Message: XMLParserTestCase.check_bad_nesting(): Use self.fail() instead of naming AssertionError directly; how PyUnit deals with the error is it's problem, not ours. ;-) --- Updated File test_xmlparser.py in package Packages/TAL -- --- test_xmlparser.py 2001/03/26 19:21:07 1.1 +++ test_xmlparser.py 2001/04/09 22:21:51 1.2 @@ -151,7 +151,7 @@ self.assert_(e.lineno == 1, "did not receive correct position information") else: - raise AssertionError("expected parse error: bad nesting") + self.fail("expected parse error: bad nesting") def check_attr_syntax(self): output = [ From guido@digicool.com Tue Apr 10 00:36:28 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:36:28 -0500 Subject: [ZPT] problems with   and
                In-Reply-To: Your message of "Mon, 09 Apr 2001 23:58:48 +0200." <3AD23098.753BCB0D@swing.be> References: <3AD23098.753BCB0D@swing.be> Message-ID: <200104092336.SAA03135@cj20424-a.reston1.va.home.com> > Sorry if this question has already been asked and answered... > > Are there anyway to preserve the browser complaint XHTML
                instead > of receiving
                which is not recognized... Oops, I think not. I'll have to fix this, because this used to be a requirement. Note that you can write
                , but then of course it won't be valid XHTML. > Further, are ther anyway to escape the transformation of & to & so > that I can use   as a tal replace argument ? Yes, use &nbsp;. Ugly but works. --Guido van Rossum (home page: http://www.python.org/~guido/) From evan@digicool.com Mon Apr 9 23:45:36 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 18:45:36 -0400 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> <200104092319.SAA02830@cj20424-a.reston1.va.home.com> Message-ID: <02e701c0c146$cb57bc10$01000001@yosemite> From: "Guido van Rossum" > Do you want me to provide a function that checks whether a program is > still valid? I propose the following API: > > import TALDefs > > TALDefs.isValidProgram((program, macros)) -> Boolean > > Note that isValidProgram() takes a single argument that's a tuple of > (program, macros) -- that way you can pass it the cached output from a > previous compilation without having to know its structure. Hmm. I already pay close attention to its structure, since I expose the macros separately. Hey, I just noticed; TALInterpreter doesn't do anything with the macros argument except hold onto it, right? Also, a macro is a valid program in its own right. So really, this should just accept a single program. The macro program will get tested for validity when a use-macro tries to retreive it. > This wouldn't be a surefire test, e.g. if you gave it a > hand-constructed tuple you might have something that passed the test In that case, the name seems to promise too much. How about TALDefs.isCurrentVersion(program)? Cheers, Evan @ digicool From evan@digicool.com Mon Apr 9 23:47:36 2001 From: evan@digicool.com (Evan Simpson) Date: Mon, 9 Apr 2001 18:47:36 -0400 Subject: [ZPT] problems with   and
                References: <3AD23098.753BCB0D@swing.be> <200104092336.SAA03135@cj20424-a.reston1.va.home.com> Message-ID: <02f101c0c147$12aab4f0$01000001@yosemite> From: "Guido van Rossum" > > Are there anyway to preserve the browser complaint XHTML
                instead > > of receiving
                which is not recognized... > > Oops, I think not. I'll have to fix this, because this used to be a > requirement. I don't understand. Inserting the space before the slash contradicts a requirement? Cheers, Evan @ digicool From guido@digicool.com Mon Apr 9 23:51:35 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:51:35 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALInterpreter.py:1.34 Message-ID: <20010409225135.6293E51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv32467 Modified Files: TALInterpreter.py Log Message: Now that self.html is set and cleared by do_mode(), also set self.endsep to the proper value there. --- Updated File TALInterpreter.py in package Packages/TAL -- --- TALInterpreter.py 2001/04/09 15:27:29 1.33 +++ TALInterpreter.py 2001/04/09 22:51:34 1.34 @@ -167,6 +167,7 @@ self.showtal = showtal self.strictinsert = strictinsert self.html = 0 + self.endsep = "/>" self.slots = {} self.currentMacro = None self.position = None, None # (lineno, offset) @@ -192,10 +193,6 @@ def __call__(self): assert self.level == 0 assert self.scopeLevel == 0 - if self.html: - self.endsep = " />" - else: - self.endsep = "/>" self.interpret(self.program) assert self.level == 0 assert self.scopeLevel == 0 @@ -233,6 +230,10 @@ def do_mode(self, mode): assert mode in ("html", "xml") self.html = (mode == "html") + if self.html: + self.endsep = " />" + else: + self.endsep = "/>" def do_setPosition(self, position): self.position = position From guido@digicool.com Mon Apr 9 23:53:16 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:53:16 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - TALGenerator.py:1.31 Message-ID: <20010409225316.33BA051014@korak.digicool.com> Update of /cvs-repository/Packages/TAL In directory korak:/tmp/cvs-serv1024 Modified Files: TALGenerator.py Log Message: When optimizing startEndTag, use " />" as the end separator when generating HTML, and "/>" for XML, instead of always using "/>". This is necessary for proper XHTML generation. --- Updated File TALGenerator.py in package Packages/TAL -- --- TALGenerator.py 2001/04/06 00:59:45 1.30 +++ TALGenerator.py 2001/04/09 22:53:15 1.31 @@ -118,6 +118,10 @@ output = [] collect = [] rawseen = cursor = 0 + if self.xml: + endsep = "/>" + else: + endsep = " />" for cursor in xrange(len(program)+1): try: item = program[cursor] @@ -133,7 +137,7 @@ if self.optimizeStartTag(collect, item[1], item[2], ">"): continue if item[0] == "startEndTag": - if self.optimizeStartTag(collect, item[1], item[2], "/>"): + if self.optimizeStartTag(collect, item[1], item[2], endsep): continue text = string.join(collect, "") if text: From guido@digicool.com Mon Apr 9 23:53:54 2001 From: guido@digicool.com (guido@digicool.com) Date: Mon, 9 Apr 2001 18:53:54 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test01.html:1.3 test02.html:1.2 test04.html:1.3 test12.html:1.3 Message-ID: <20010409225354.5463C51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test/output In directory korak:/tmp/cvs-serv1539 Modified Files: test01.html test02.html test04.html test12.html Log Message: Update HTML test output for space before /> --- Updated File test01.html in package Packages/TAL -- --- test01.html 2001/04/07 19:26:08 1.2 +++ test01.html 2001/04/09 22:53:53 1.3 @@ -58,8 +58,8 @@ - - + +  

                Header Level 3

                 

                Header Level 3

                --- Updated File test02.html in package Packages/TAL -- --- test02.html 2001/03/27 16:39:00 1.1 +++ test02.html 2001/04/09 22:53:53 1.2 @@ -37,12 +37,12 @@ CANADA - + ATTN: PAULINE DEGRASSI - - - - + + + + --- Updated File test04.html in package Packages/TAL -- --- test04.html 2001/04/07 19:26:08 1.2 +++ test04.html 2001/04/09 22:53:53 1.3 @@ -6,7 +6,7 @@
                - +
                • @@ -19,7 +19,7 @@
                - +
                • --- Updated File test12.html in package Packages/TAL -- --- test12.html 2001/04/07 19:26:08 1.2 +++ test12.html 2001/04/09 22:53:53 1.3 @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - + From guido@digicool.com Tue Apr 10 00:57:37 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 18:57:37 -0500 Subject: [ZPT] problems with   and
                  In-Reply-To: Your message of "Mon, 09 Apr 2001 23:58:48 +0200." <3AD23098.753BCB0D@swing.be> References: <3AD23098.753BCB0D@swing.be> Message-ID: <200104092357.SAA03324@cj20424-a.reston1.va.home.com> > Are there anyway to preserve the browser complaint XHTML
                  instead > of receiving
                  which is not recognized... This is now fixed in the CVS tree and will be incorporated in the 1.1 release tomorrow. --Guido van Rossum (home page: http://www.python.org/~guido/) From guido@digicool.com Tue Apr 10 01:04:21 2001 From: guido@digicool.com (Guido van Rossum) Date: Mon, 09 Apr 2001 19:04:21 -0500 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 In-Reply-To: Your message of "Mon, 09 Apr 2001 18:45:36 -0400." <02e701c0c146$cb57bc10$01000001@yosemite> References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> <200104072102.QAA24642@cj20424-a.reston1.va.home.com> <029901c0c13b$50aa8e80$01000001@yosemite> <200104092319.SAA02830@cj20424-a.reston1.va.home.com> <02e701c0c146$cb57bc10$01000001@yosemite> Message-ID: <200104100004.TAA03404@cj20424-a.reston1.va.home.com> > From: "Guido van Rossum" > > Do you want me to provide a function that checks whether a program is > > still valid? I propose the following API: > > > > import TALDefs > > > > TALDefs.isValidProgram((program, macros)) -> Boolean > > > > Note that isValidProgram() takes a single argument that's a tuple of > > (program, macros) -- that way you can pass it the cached output from a > > previous compilation without having to know its structure. [Evan] > Hmm. I already pay close attention to its structure, since I expose the > macros separately. Hey, I just noticed; TALInterpreter doesn't do anything > with the macros argument except hold onto it, right? Also, a macro is a > valid program in its own right. So really, this should just accept a single > program. The macro program will get tested for validity when a use-macro > tries to retreive it. Hm, but macros don't have a version number of their own. Should they? > > This wouldn't be a surefire test, e.g. if you gave it a > > hand-constructed tuple you might have something that passed the test > > In that case, the name seems to promise too much. How about > TALDefs.isCurrentVersion(program)? OK. I just realized: there's an issue with mixing XML macros and HTML code or vice versa: the macros are optimized/precompiled for the mode used to compile them. To fix this I would probably need another inquiry function that returns the mode ("xml" or "html") from a program, *and* add version *and* mode instructions to all macros. --Guido van Rossum (home page: http://www.python.org/~guido/) From richard@bizarsoftware.com.au Tue Apr 10 00:42:26 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Tue, 10 Apr 2001 09:42:26 +1000 Subject: [ZPT] playing with stylesheets in ZPT? References: <3AD1711E.74C7DD75@bizarsoftware.com.au> <20010409112037.A31388@zopatista.com> Message-ID: <3AD248E2.E528D248@bizarsoftware.com.au> Martijn Pieters wrote: > On Mon, Apr 09, 2001 at 06:21:50PM +1000, richard@bizarsoftware.com.au wrote: > > Let's say that we have an object tree where every page in the tree has the > > following in it: > > > > > > Hmm.. I'd make the stylesheet a Python Script or something.. Can't - the stylesheet is created in the page by a web designer. We want them to be able to create the page with the minimum of fuss. The entire ZPT layout must be viewable and editable in Dreamweaver, both before it's "uploaded" to the Product which is rendering it and afterwards. I can't just remove the stylesheet information from the page and place it elsewhere. We can't move the CSS out to a linked stylesheet, because Netscape is really picky about where you put background image declarations, and a linked stylesheet doesn't cut its mustard. Ultimately this is all Netscape 4.7's fault :) > Or you could > go the CMF way and make the CSS Stylesheet external but include it in the > case of Netscape 4 clients. I converted that to ZPT for the Internet World > demo and that worked great. As a rule, we never, ever, use linked stylesheets. Even IE gets it wrong sometimes. > I used the following code to include the stylesheet (which keeps working > in Dreamweaver and GoLive if you fill in a correct href attribute on the > tag): > > tal:replace="structure here/css_inline_or_link" /> If the stylesheet is linked in, this is fine. But if the stylesheet is in the page, I can't do anything in ZPT at the moment to this end. > [code snipped] We have a very similar thing for the ZPT - the page is parsed at cook time and tal:attributes statements are inserted into and tags to make them do the "correct" thing at render time. I just need something I can do for the _content_ of the
              Top Left
              Bottom left +

              Some headline

              This is the real contents of the bottom right slot.


              --- Updated File test11.html in package Packages/TAL -- --- test11.html 2001/03/27 16:33:31 1.1 +++ test11.html 2001/04/07 19:26:08 1.2 @@ -1,5 +1,5 @@ - + bar -

              bad boy!

              -

              x undefined

              +

              bad boy!

              +

              x undefined

              --- Updated File test11.xml in package Packages/TAL -- --- test11.xml 2001/03/27 16:33:31 1.1 +++ test11.xml 2001/04/07 19:26:08 1.2 @@ -1,5 +1,5 @@ - + bar -

              bad boy!

              -

              x undefined

              +

              bad boy!

              +

              x undefined

              --- Updated File test12.html in package Packages/TAL -- --- test12.html 2001/04/06 21:38:24 1.1 +++ test12.html 2001/04/07 19:26:08 1.2 @@ -1,24 +1,24 @@ - + - - - - - - - - - - - + + + + + + + + + + + - + - - + + From guido@digicool.com Sat Apr 7 20:51:56 2001 From: guido@digicool.com (guido@digicool.com) Date: Sat, 7 Apr 2001 15:51:56 -0400 (EDT) Subject: [ZPT] CVS: Packages/TAL - test_htmltalparser.py:1.11 Message-ID: <20010407195156.111EE51014@korak.digicool.com> Update of /cvs-repository/Packages/TAL/test In directory korak:/tmp/cvs-serv10986 Modified Files: test_htmltalparser.py Log Message: Update test output to match version 1.0.1 of the code generator. All test should succeed now (both TAL/test/run.py and TAL/runtest.py). --- Updated File test_htmltalparser.py in package Packages/TAL -- --- test_htmltalparser.py 2001/04/06 19:54:18 1.10 +++ test_htmltalparser.py 2001/04/07 19:51:55 1.11 @@ -138,7 +138,7 @@ def check_define_macro(self): macro = [('startTag', 'p', - [('metal:define-macro', 'M', 'macroHack')]), + [('metal:define-macro', 'M', 'metal')]), ('rawtext', 'booh

              ')] program = [ ('setPosition', (1, 0)), @@ -152,16 +152,18 @@ ('setPosition', (1, 0)), ('useMacro', 'M', '$M$', {}, - [('rawtext', '

              booh

              ')]), + [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]), + ('rawtext', 'booh

              ')]), ]) def check_define_slot(self): macro = [ - ('startTag', 'p', [('metal:define-macro', 'M', 'macroHack')]), + ('startTag', 'p', [('metal:define-macro', 'M', 'metal')]), ('rawtext', 'foo'), ('setPosition', (1, 29)), ('defineSlot', 'S', - [('rawtext', 'spam')]), + [('startTag', 'span', [('metal:define-slot', 'S', 'metal')]), + ('rawtext', 'spam
              ')]), ('rawtext', 'bar

              '), ] program = [('setPosition', (1, 0)), @@ -177,11 +179,14 @@ ('setPosition', (1, 0)), ('useMacro', 'M', '$M$', - {'S': [('rawtext', 'spam')]}, - [('rawtext', '

              foo'), + {'S': [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]), + ('rawtext', 'spam')]}, + [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]), + ('rawtext', 'foo'), ('setPosition', (1, 26)), ('fillSlot', 'S', - [('rawtext', 'spam')]), + [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]), + ('rawtext', 'spam')]), ('rawtext', 'bar

              ')]), ]) @@ -196,21 +201,26 @@ ('setPosition', (1, 0)), ('beginScope',), ('setLocal', 'xyzzy', '$string:spam$'), - ('rawtext', '

              '), + ('startTag', 'p', [('tal:define', 'xyzzy string:spam', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) self._run_check("

              ", [ ('setPosition', (1, 0)), ('beginScope',), ('setLocal', 'xyzzy', '$string:spam$'), - ('rawtext', '

              '), + ('startTag', 'p', + [('tal:define', 'local xyzzy string:spam', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) self._run_check("

              ", [ ('setPosition', (1, 0)), ('beginScope',), ('setGlobal', 'xyzzy', '$string:spam$'), - ('rawtext', '

              '), + ('startTag', 'p', + [('tal:define', 'global xyzzy string:spam', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) self._run_check("

              ", [ @@ -218,7 +228,8 @@ ('beginScope',), ('setLocal', 'x', '$string:spam$'), ('setLocal', 'y', '$x$'), - ('rawtext', '

              '), + ('startTag', 'p', [('tal:define', 'x string:spam; y x', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) self._run_check("

              ", [ @@ -226,7 +237,8 @@ ('beginScope',), ('setLocal', 'x', '$string:;;$'), ('setLocal', 'y', '$x$'), - ('rawtext', '

              '), + ('startTag', 'p', [('tal:define', 'x string:;;;;; y x', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) self._run_check( @@ -236,8 +248,9 @@ ('setLocal', 'x', '$string:spam$'), ('setGlobal', 'y', '$x$'), ('setLocal', 'z', '$y$'), - ('rawtext', - '

              '), + ('startTag', 'p', + [('tal:define', 'x string:spam; global y x; local z y', 'tal')]), + ('rawtext', '

              '), ('endScope',), ]) @@ -247,27 +260,28 @@ ('rawtext', '

              '), ('setPosition', (1, 3)), ('condition', '$python:1$', - [('rawtext', - 'foo')]), + [('startTag', 'span', [('tal:condition', 'python:1', 'tal')]), + ('rawtext', 'foo')]), ('rawtext', '

              '), ]) def check_content(self): self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), - ('rawtext', '

              '), + ('startTag', 'p', [('tal:content', 'string:foo', 'tal')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]), ('rawtext', '

              '), ]) self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), - ('rawtext', '

              '), + ('startTag', 'p', [('tal:content', 'text string:foo', 'tal')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]), ('rawtext', '

              '), ]) self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), - ('rawtext', '

              '), + ('startTag', 'p', + [('tal:content', 'structure string:
              ', 'tal')]), ('insertStructure', '$string:
              $', {}, [('rawtext', 'bar')]), ('rawtext', '

              '), ]) @@ -276,18 +290,21 @@ self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), ('insertText', '$string:foo$', - [('rawtext', '

              bar

              ')]), + [('startTag', 'p', [('tal:replace', 'string:foo', 'tal')]), + ('rawtext', 'bar

              ')]), ]) self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), ('insertText', '$string:foo$', - [('rawtext', '

              bar

              ')]), + [('startTag', 'p', [('tal:replace', 'text string:foo', 'tal')]), + ('rawtext', 'bar

              ')]), ]) self._run_check("

              bar

              ", [ ('setPosition', (1, 0)), ('insertStructure', '$string:
              $', {}, - [('rawtext', - '

              bar

              ')]), + [('startTag', 'p', + [('tal:replace', 'structure string:
              ', 'tal')]), + ('rawtext', 'bar

              ')]), ]) def check_repeat(self): @@ -296,10 +313,11 @@ ('setPosition', (1, 0)), ('beginScope',), ('loop', 'x', '$python:(1,2,3)$', - [('rawtext', '

              '), + [('startTag', 'p', [('tal:repeat', 'x python:(1,2,3)', 'tal')]), ('setPosition', (1, 33)), ('insertText', '$x$', - [('rawtext', 'dummy')]), + [('startTag', 'span', [('tal:replace', 'x', 'tal')]), + ('rawtext', 'dummy')]), ('rawtext', '

              ')]), ('endScope',), ]) @@ -313,7 +331,7 @@ [('href', 'foo', 'replace', '$string:http://www.zope.org$'), ('name', 'bar'), ('tal:attributes', - 'href string:http://www.zope.org; x string:y'), + 'href string:http://www.zope.org; x string:y', 'tal'), ('x', '', 'replace', '$string:y$')]), ('rawtext', 'link'), ]) @@ -322,9 +340,10 @@ ('setPosition', (1, 0)), ('insertStructure', '$string:$', {'src': '$string:foo.png$'}, - [('rawtext', - '

              duh

              ')]), + [('startTag', 'p', + [('tal:replace', 'structure string:', 'tal'), + ('tal:attributes', 'src string:foo.png', 'tal')]), + ('rawtext', 'duh

              ')]), ]) def check_on_error(self): @@ -332,12 +351,14 @@ "tal:content='notHere'>okay

              ", [ ('setPosition', (1, 0)), ('onError', - [('rawtext', - '

              '), + [('startTag', 'p', + [('tal:on-error', 'string:error', 'tal'), + ('tal:content', 'notHere', 'tal')]), ('insertText', '$notHere$', [('rawtext', 'okay')]), ('rawtext', '

              ')], - [('rawtext', - '

              '), + [('startTag', 'p', + [('tal:on-error', 'string:error', 'tal'), + ('tal:content', 'notHere', 'tal')]), ('insertText', '$string:error$', []), ('rawtext', '

              ')]), ]) @@ -346,11 +367,13 @@ ('setPosition', (1, 0)), ('onError', [('insertText', '$notHere$', - [('rawtext', - '

              okay

              ')])], - [('rawtext', - '

              '), + [('startTag', 'p', + [('tal:on-error', 'string:error', 'tal'), + ('tal:replace', 'notHere', 'tal')]), + ('rawtext', 'okay

              ')])], + [('startTag', 'p', + [('tal:on-error', 'string:error', 'tal'), + ('tal:replace', 'notHere', 'tal')]), ('insertText', '$string:error$', []), ('rawtext', '

              ')]), ]) From guido@digicool.com Sat Apr 7 22:02:17 2001 From: guido@digicool.com (Guido van Rossum) Date: Sat, 07 Apr 2001 16:02:17 -0500 Subject: [ZPT] CVS: Packages/TAL - README.txt:1.14 In-Reply-To: Your message of "Fri, 06 Apr 2001 18:04:24 EST." <001e01c0beed$ec449ca0$2a01a8c0@evansys> References: <20010406213327.F35B851014@korak.digicool.com> <00b401c0bee2$2d1f0d70$2a04000a@evansys> <200104062245.RAA21638@cj20424-a.reston1.va.home.com> <001e01c0beed$ec449ca0$2a01a8c0@evansys> Message-ID: <200104072102.QAA24642@cj20424-a.reston1.va.home.com> Hi Evan, I've checked in the changes to suppress output of TAL, METAL and relevant XMLNS attributes. These are suppressed by default when 'tal=1' is passed to the TALInterpreter() constructor. You can force showing them by passing this constructor 'showtal=1', and force hiding them (not sure what good that is :-) with 'showtal=0'. As far as I'm concerned, this can go into the 1.0.1 bugfix release. I've updated the TALDefs.TAL_VERSION constant to 1.0.1. Since you're not yet making the TAL program persistent, this shouldn't break anything. But given that the HTML parser is relatively slow, you might want to change this and cache the program and macros in persistent variables. If you make that change, we need to talk about what to do about old programs -- I could either provide a function that checks whether a program is still valid, or I could try to make the TALInterpreter support older versions (with reason). Or we could do both. Do you want the simplified handling of structure replace/content in 1.0.1? --Guido van Rossum (home page: http://www.python.org/~guido/) From geirh@funcom.com Sun Apr 8 20:21:23 2001 From: geirh@funcom.com (=?iso-8859-1?Q?Geir_B=E6kholt?=) Date: Sun, 8 Apr 2001 21:21:23 +0200 Subject: SV: [ZPT] Authoring tools and tag-nesting problems Message-ID: <01c0c061$1972f9a0$386547c1@default> agree on the span tag being the safest for template use , but what i really want to investigate is how ZPT fares in conjunction with Dreamweaver's template-locking mechanisms.. DW utilizes its own set of templates on the filesystem , and keeps them un-editable in DW through some special set of HTML comments.. I'll set up an experiment on faking these in METAL-macros as soon as i get some spare time. could really be a helper for the WYSIWYG people.. ;-) Geir Bækholt geirh@funcom.com >On Thu, 5 Apr 2001, Chris Withers wrote: > >Speaking of tags, I presume that there is another danger here: >while Dreamweaver may leave tag attributes alone, if you >unbold that section of text it is presumably going to delete the >b tag *and its attributes*. Meaning that using to hold your >TAL code is probably almost always preferable to using a tag with >a more specific function. > >--RDM > > >_______________________________________________ >ZPT mailing list >ZPT@zope.org >http://lists.zope.org/mailman/listinfo/zpt > From geirh@funcom.com Sun Apr 8 20:36:51 2001 From: geirh@funcom.com (=?iso-8859-1?Q?Geir_B=E6kholt?=) Date: Sun, 8 Apr 2001 21:36:51 +0200 Subject: SV: [ZPT] nesting macros with slots ? Message-ID: <01c0c063$42b000e0$386547c1@default> Sorry.. was to tied up in trying to make it work to see it clearly.. Turns out it is more bixarre than i first thought I am devising use-cases for ZPT to see if it would fit our next (rather large) project, and my initial thought was this : 1 ) It would be neat to have a macro-template with loads of little snippets (METAL-macros) to be reused around the site.. 2 ) It would also be neat to have a commonLookAndFeel-template for the WYSIWYG-people to use for adding pages of content and stuff. - but i would prefer to avoid writing the definitions for the common snippets (mentioned in (1)) again for the commonLookAndFeel.. - feels stupid to maintain two versions.. 3 ) thus i would like to use the macros from (1) in the macro i define in (2) , although both are macro-definitions (so nesting definitions/nesting calls becomes a question i cannot answer , because i cannot quite see which it would be) 4 ) all this would seem simple, if not for the issue of slots.. - i would love the macros defined in 1 to have slots , and have these slots filled , not in 2 , but in the final pages utilizing 2's commonLookAndFeel template.. Argh ! Turns out it was a somewhat more bizarre problem than i initially thought, and i should perhaps just shelve it , although it would be a really neat way to work.. Geir Bækholt geirh@funcom.com > >Sorry, I don't understand what you want to do. Do you want to nest >macro *definitions* or macro *calls*? You can nest calls without >problems. You may even be able to nest definitions! > >But it would all be much clearer for me if you could give an explicit >example of what you want to do. > >--Guido van Rossum (home page: http://www.python.org/~guido/) > >_______________________________________________ >ZPT mailing list >ZPT@zope.org >http://lists.zope.org/mailman/listinfo/zpt > From richard@bizarsoftware.com.au Mon Apr 9 00:01:37 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 09:01:37 +1000 Subject: [ZPT] My First Post References: Message-ID: <3AD0EDD1.D2DBC493@bizarsoftware.com.au> "R. David Murray" wrote: > On Wed, 4 Apr 2001 richard@bizarsoftware.com.au wrote: > > TAL statements: define, attributes, condition, content, replace, repeat > > - why is attributes plural? It may be used to define a single attribute > > replacement. Similarly, define may be used for either a single or multiple > > definition. So as far as I'm concerned, attributes should just be > > attribute. Or define should be definitions. One or the other. Or is it just > > Too Late to be bringing this stuff up? > > IMO, the spelling used is correct. 'define' is a verb, whereas > 'attributes' is a noun. At least, that's the way I hear it . OK, so why is one a noun and one a verb? That part of my post was all about consistency, or the lack thereof :) And why does 'attributes', as a noun, still have to be plural? Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Mon Apr 9 00:24:39 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 09:24:39 +1000 Subject: [ZPT] Extending tal:condition References: <017b01c0bd7f$b5afd6b0$2a01a8c0@evansys> <3ACBEC92.9E01F759@bizarsoftware.com.au> <3ACD1FF3.C121386F@bizarsoftware.com.au> <3ACD20EC.75F05C73@bizarsoftware.com.au> <200104061623.LAA14679@cj20424-a.reston1.va.home.com> <02d801c0beb3$246fbd20$2a04000a@evansys> <200104061755.MAA15211@cj20424-a.reston1.va.home.com> <003601c0becf$0db27200$2a04000a@evansys> <200104062044.PAA15797@cj20424-a.reston1.va.home.com> <008e01c0bedf$c42dbc50$2a04000a@evansys> <200104062228.RAA16537@cj20424-a.reston1.va.home.com> Message-ID: <3AD0F337.3A9617BC@bizarsoftware.com.au> Guido van Rossum wrote: > > > The sort of thing I'm thinking of, call it "if:", would evaluate it's > > expression and catch any traversal errors (traversal would be modified > > to raise a new exception if a step failed in any way). On such an > > error, it would return (or raise) doNothing. TALInterpreter would be > > modified so that 'content', 'replace', and 'attributes' would do nothing > > if they receive this signal. That way we could write: > > > >

              It isn't here.

              > > > > If "path:request/might_be_here" resolves, then its value replaces the > > paragraph content, otherwise the default text remains. Likewise: > > > > Go here > > > > "if::" could also be "optional:", or whatever. > > OK, good. Now I understand. Should we do this for 1.1? (It's not > hard!) As long as I don't have to wait too long for 1.1, I'm happy for this. I'm using 'lazy' at the moment, and it won't be too hard renaming it to whatever the keyword ends up being. My vote is against 'if' and 'optional'. 'if' could be confused too easily with the semantics of tal:condition. It implies that there's more going on - that the path is being evaluated for truth. 'optional' doesn't really have any indication of what's really going on. Is there some reason why we couldn't just make use of 'exists'? It has no real use in the content/replace TAL operations. Make doNothing a false value. Or is that overloading the 'exists' keyword too much? And what's the behaviour of the test in tal:replace? I think it'd be the same as replace/content - the tag stays as is, with no further processing. Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From richard@bizarsoftware.com.au Mon Apr 9 00:31:53 2001 From: richard@bizarsoftware.com.au (richard@bizarsoftware.com.au) Date: Mon, 09 Apr 2001 09:31:53 +1000 Subject: [ZPT] Authoring tools and tag-nesting problems References: Message-ID: <3AD0F4E9.5F7F07CA@bizarsoftware.com.au> "R. David Murray" wrote: > > On Thu, 5 Apr 2001, Chris Withers wrote: > > The other option, and I know this is far from perfect, would be to use CSS > > rather than things like FONT tags to do your styling. Dunno how Dreamweaver > > or GoLive fair with this though, not to mention browsers... > > In the small amount of Dreamweaver HTML output I have looked at, I was > very unimpressed by its use of and (etc) tags. It did not > seem to make any attempt to scope the tags to reduce redundancies and > extra tags. Hah! Have you seen it
              content