Search

Enter a search word or two and press return to see the search results.

Who am I?

Hi, I’m Graeme and these are my notes, from my messy desk. I started this blog because Google proved to be more useful at finding content than anything else I’ve used.

So I started adding my own content in the hopes that Google would index it and allow me to find things again in the future.

It works.

You can find out more about me here, and you should follow me on Twitter here.

Keeping up

You can automatically receive new content here by subscribing to the “Blog RSS” (link below). This is the easiest way to keep up with what I write here.  See this BBC article for a good introduction on RSS and keeping up with the goings on of the Internet more easily.

« That was the weekend that was | Main | Dear Santa Claus »
Friday
Oct142005

Zope Page Template weirdness

So we were having a 'discussion' on the work mailing list about a change I'd made to the UI code for MailManager. Given the following page template:

[code lang="xml"]



The title



xxx
yyy



[/code]

both Andy and Kev asserted that it would render to:

[code lang="xml"]







xxx

yyy



[/code]

while I was asserting that it rendered to:

[code lang="xml"]







xxx
yyy



[/code]

(note the difference in the rendering of the 'selected' attribute of the <option> tag.)

I had distilled mine down from the MailManager code, as a test instance, whereas both Kev & Andy had created a fresh template in the ZMI. And both of us appeared to be right. We wondered if it was a difference in platform -- I'm working on my laptop, with python 2.4 & Zope 2.7.7. But no. The difference is that I'm rendering the files as content-type text/xml (which Zope kindly defaults to if it encounters a file starting <?xml ... whereas they were forcing the content-type to text/html (the default if you create a template through the ZMI). If you force the content-type to text/xml in the ZMI you'll see the same results as I get.

So it turns out that exactly the same Zope Page Templates will render slightly differently, depending on whether or not they are marked as being HTML or XML. Cool.

(I can understand why they are pulled apart by different parsers, since it's so much nicer to use a proper XML parser if you're expecting valid XML -- and leave the grotty excuses for HTML that one sometimes finds to another lame, hacky thing -- but to not mangle them into the same AST and use a unified generator at the other end?)

When I've got more time, I should go file bugs. But I've got an alpha of MailManager 2.1 to release this afternoon, so I'd better get on with that or there'll be no getting to go to the pub for me!

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (1)

There is a recent thread on the zope-zpt mailing list about just this topic.

If you *need* HTML as output, rather than XHTML, then you *can't* allow the XML-isms to
get emitted; ZPTs HTML mode forces "empty" tags to have the extra space added, for
instance ('' instaead of '').

There may be a couple of others, mostly to do with working around "quirks mode" in the
browsers.

October 17, 2005 | Unregistered CommenterTres Seaver

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>