Fixing the ZPT (Chameleon?) DOCTYPE conundrum

6 messages Options
Embed this post
Permalink
Alexander Limi

Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
In the current Plone main_template we have the following code:

   <metal:page define-macro="master">
   <tal:doctype tal:replace="structure string:<!DOCTYPE html PUBLIC
     "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"  
/>

As part of creating a new theme for Plone 4, I'd like to clean this up,  
and define the whole page macro on the <html> tag, as ZPT intends you to  
do. The code would then look like this:

   <!DOCTYPE html>
   <html metal:define-macro="master">

The problem with this is that the doctype is then outside of the master  
macro, so any page template that fills the slots in the template will have  
to define its own doctype. People never remember to do this, and it was  
indeed a problem in Plone 1.0, since the browser goes into quirks mode if  
you forget.

I'd like a better solution for this, but it would probably involve fixing  
up ZPT (and possibly Chameleon) to know what to do if there's a missing  
doctype. There's a related problem when you are rendering XML, the  
mandatory <?xml> header:

   <?xml version="1.0" encoding="UTF-8"?>

In my opinion, ZPT/Chameleon should special-case this, since it's hard to  
handle with the standard structures — since it doesn't behave like other  
tags (and they aren't tags, technically).

A configuration option that allows you to specify the header for a given  
rendered MIME type would be ideal. That way, you could specify the above  
header for application/xml, and a doctype header for text/html.


We have the following options:

1) Add a DOCTYPE declaration to every page template in Plone and in add-on  
products. If people forget this, the page will be rendered in quirks mode  
— not a good thing, you get the wrong box model, etc. I don't think this  
is a realistic option.

2) Figure out a way to make ZPT (and Chameleon?) specify a default doctype  
if one is missing. This is my preferred solution, but I have no idea how  
hard it would be to implement.

3) Do nothing, and live with ugly/confusing markup.

Thoughts and ideas appreciated.

--
Alexander Limi · http://limi.net


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Alexander Limi · http://limi.net

Malthe Borch-2

Re: Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
Alexander Limi wrote:
> 2) Figure out a way to make ZPT (and Chameleon?) specify a default doctype  
> if one is missing. This is my preferred solution, but I have no idea how  
> hard it would be to implement.

In Chameleon you can provide a ``doctype`` keyword argument to the
template constructor which will act as a default doctype.

\malthe


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Alexander Limi

Re: Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
On Sun, 12 Jul 2009 01:21:39 -0700, Malthe Borch  
<[hidden email]> wrote:

> Alexander Limi wrote:
>> 2) Figure out a way to make ZPT (and Chameleon?) specify a default  
>> doctype
>> if one is missing. This is my preferred solution, but I have no idea how
>> hard it would be to implement.
>
> In Chameleon you can provide a ``doctype`` keyword argument to the
> template constructor which will act as a default doctype.

Cool, I assume you do doctype="<!DOCTYPE html>" then?

Does anyone know if something like this could be added to ZPT easily?

--
Alexander Limi · http://limi.net


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Alexander Limi · http://limi.net

Malthe Borch-2

Re: Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
Alexander Limi wrote:
> Cool, I assume you do doctype="<!DOCTYPE html>" then?

Yes; you may also important standard doctype strings from
``chameleon.core.doctypes``.

\malthe


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Alexander Limi

Re: Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
In reply to this post by Malthe Borch-2
On Sun, 12 Jul 2009 01:21:39 -0700, Malthe Borch  
<[hidden email]> wrote:

> Alexander Limi wrote:
>> 2) Figure out a way to make ZPT (and Chameleon?) specify a default  
>> doctype
>> if one is missing. This is my preferred solution, but I have no idea how
>> hard it would be to implement.
>
> In Chameleon you can provide a ``doctype`` keyword argument to the
> template constructor which will act as a default doctype.

Is there anybody out there that could help us add this for ZPT? It would  
simplify main_template for 4.0, and doesn't seem like it's an invasive  
change (since if you don't pass in anything, it'll just behave as it used  
to).

Now that ZPT is a separate egg in 2.12, we should also be able to do this  
change without requiring a monolithic release of Zope, if I understand the  
new setup correctly?

--
Alexander Limi · http://limi.net


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Alexander Limi · http://limi.net

Malthe Borch-2

Re: Fixing the ZPT (Chameleon?) DOCTYPE conundrum

Reply Threaded More More options
Print post
Permalink
On 10/7/09 8:49 PM, Alexander Limi wrote:
> Is there anybody out there that could help us add this for ZPT? It would
> simplify main_template for 4.0, and doesn't seem like it's an invasive
> change (since if you don't pass in anything, it'll just behave as it used
> to).

I've had a look just now; it's not obvious to me where to plug in this
functionality.

Actually getting it right in Chameleon was a challenge, mostly because
of expat; it really wants to understand XML and that's sometimes a bit
contrary to the goals of a page template engine.

\malthe


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers