[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Jasper Op de Coul

New submission from Jasper Op de Coul :

I have a single macro with a doctype and the html/head/body structure and some
slots that I
use in every template. When using Chameleon <=1.1.1 the doctype is inserted in
the rendered HTML. 

With Chameleon 1.1.2 the doctype is missing, causing mayhem in IE (quirks mode).
I had to add the doctype to each of my templates to get it working again. 
This is obviously related to issue116. 

I would think this is a bug, but maybe it isn't and putting the doctype in the
templates makes more sense. Maybe we can have best of both worlds, xml/doctype
declarations can be made everywhere, but exact duplicates should be removed.

--
messages: 374
nosy: JasperOC
priority: bug
status: unread
title: Chameleon - can't create xml and doctype declarations from macro

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Malthe Borch

Malthe Borch  added the comment:

I'm not sure I understand exactly.

If you have the time, please demonstrate this with a failing test (commit if 
you can, we can always 
change our collective minds on it later).

Failing tests are great because they prevent immature releases.

--
status: unread -> chatting

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Jasper Op de Coul

Jasper Op de Coul  added the comment:

I don't have commit rights to the repoze repository but I attached a patch. 
The last testcase is failing, although this worked in previous versions of
Chameleon.

__
Repoze Bugs 

__Index: src/chameleon/zpt/template.txt
===
--- src/chameleon/zpt/template.txt	(revision 8327)
+++ src/chameleon/zpt/template.txt	(working copy)
@@ -426,6 +426,70 @@
 
   
 
+Doctype declarations
+
+
+A macro can have an xml and/or doctype declaration.
+
+  >>> pagemacro = PageTemplate("""
+  ... http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+  ... http://www.w3.org/1999/xhtml";
+  ...   metal:define-macro="master">
+  ...   
+  ... 
+  ...   Content goes here
+  ... 
+  ...   
+  ... 
+  ... """)
+
+A pagetemplate can also contain a doctype
+
+  >>> template = PageTemplate("""
+  ... http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+  ... http://www.w3.org/1999/xhtml";
+  ...  metal:use-macro="macro.macros['master']">
+  ...   
+  ... Content
+  ...   
+  ... """)
+
+The final rendered result should have only one doctype, although the doctype
+is defined both on the macro and the template.
+(http://bugs.repoze.org/issue116)
+
+  >>> print template(macro=pagemacro)
+  http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+  http://www.w3.org/1999/xhtml";>
+
+  
+  Content
+
+  
+
+  
+
+If the template contains no doctype, the one from the macro should be used
+
+  >>> template = PageTemplate("""
+  ... http://www.w3.org/1999/xhtml";
+  ...  metal:use-macro="macro.macros['master']">
+  ...   
+  ... Content
+  ...   
+  ... """)
+
+  >>> print template(macro=pagemacro)
+  http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+  http://www.w3.org/1999/xhtml";>
+
+  
+  Content
+
+  
+
+  
+
 Error handling
 --
 
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Shane Hathaway

Shane Hathaway  added the comment:

I ran into the same issue. The following code worked with 1.1.1 but fails with
1.1.2:

from chameleon.zpt.template import PageTemplate

master = PageTemplate('''\




content here



''')

page = PageTemplate('''\


Hello, world!


''')

s = page(master=master)

assert 'Hello, world!' in s
assert s.startswith('')

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin Kalupson

Kevin Kalupson  added the comment:

I wouldn't expect the the xml headers in a macro template to be applied to the
page template being rendered.  It makes no sense to me that an element not
contained within a macro definition would be applied to the page calling the
macro under any situation.

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-18 Thread Jasper Op de Coul

Jasper Op de Coul  added the comment:

I tested it, passing a reference to the actual template is working. 

I added a patch for the bfgsite example application to use this new syntax.
This is what I based my template code on, and  it still uses the
doctype-in-macro way.
However, it seems the bfgsite example still uses chameleon 1.1.1, so don' t
apply it yet.

Thanks
Jasper

__
Repoze Bugs 

__Index: bfgsite/views/templates/paste_entry.pt
===
--- bfgsite/views/templates/paste_entry.pt	(revision 8509)
+++ bfgsite/views/templates/paste_entry.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/areyousure.pt
===
--- bfgsite/views/templates/areyousure.pt	(revision 8509)
+++ bfgsite/views/templates/areyousure.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/tutorial.pt
===
--- bfgsite/views/templates/tutorial.pt	(revision 8509)
+++ bfgsite/views/templates/tutorial.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/tutorialbin_manage.pt
===
--- bfgsite/views/templates/tutorialbin_manage.pt	(revision 8509)
+++ bfgsite/views/templates/tutorialbin_manage.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/profile_edit.pt
===
--- bfgsite/views/templates/profile_edit.pt	(revision 8509)
+++ bfgsite/views/templates/profile_edit.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/pastebin.pt
===
--- bfgsite/views/templates/pastebin.pt	(revision 8509)
+++ bfgsite/views/templates/pastebin.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/index.pt
===
--- bfgsite/views/templates/index.pt	(revision 8509)
+++ bfgsite/views/templates/index.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 http://www.google.com/jsapi";>
Index: bfgsite/views/templates/login.pt
===
--- bfgsite/views/templates/login.pt	(revision 8509)
+++ bfgsite/views/templates/login.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";
-metal:use-macro="api.main_template.macros['master']">
+metal:use-macro="api.main_template">
 
   
 
Index: bfgsite/views/templates/documentation.pt
===
--- bfgsite/views/templates/documentation.pt	(revision 8509)
+++ bfgsite/views/templates/documentation.pt	(working copy)
@@ -2,7 +2,7 @@
 xmlns="http://www.w3.org/1999/xhtml"; 
 xmlns:tal="http://xml.zope.org/namespaces/tal";
 xmlns:metal="http://xml.zope.org/namespaces/metal";

[Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2013-12-17 Thread Tres Seaver

Tres Seaver  added the comment:

Please report / track Chameleon issues on Github:

  https://github.com/malthe/chameleon/issues

--
status: chatting -> deferred

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
https://lists.repoze.org/mailman/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Malthe Borch
On 4 March 2010 19:38, Jasper Op de Coul  wrote:
> I don't have commit rights to the repoze repository but I attached a patch.
> The last testcase is failing, although this worked in previous versions of
> Chameleon.

I've committed this.

These seem like fairly critical regressions; I'll try to look at them asap.

\malthe
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Malthe Borch
On 4 March 2010 22:02, Kevin Kalupson  wrote:
> I wouldn't expect the the xml headers in a macro template to be applied to the
> page template being rendered.  It makes no sense to me that an element not
> contained within a macro definition would be applied to the page calling the
> macro under any situation.

I sort of agree, except how else would we provide this functionality?
Or is it actually the case that it doesn't make sense for a macro to
control these headers –– I suspect it is.

Plone's answer to this is to have its wrapper template manually write
out the XML declaration or maybe just the DOCTYPE. That seems kind of
crude as well.

\malthe
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Shane Hathaway
Malthe Borch wrote:
> On 4 March 2010 22:02, Kevin Kalupson  wrote:
>> I wouldn't expect the the xml headers in a macro template to be applied to 
>> the
>> page template being rendered.  It makes no sense to me that an element not
>> contained within a macro definition would be applied to the page calling the
>> macro under any situation.
> 
> I sort of agree, except how else would we provide this functionality?
> Or is it actually the case that it doesn't make sense for a macro to
> control these headers –– I suspect it is.

 From a template developer's POV, it's useful to apply the same XML 
declarations throughout a site using metal.  The current syntax is 
non-obvious and perhaps problematic, but workable.  Some other syntax 
might be better, but let's not break the current syntax in the 1.1 branch.

Shane

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin J. Kalupson


On 3/4/10 2:08 PM, Malthe Borch wrote:
> On 4 March 2010 22:02, Kevin Kalupson  wrote:
>> I wouldn't expect the the xml headers in a macro template to be applied to 
>> the
>> page template being rendered.  It makes no sense to me that an element not
>> contained within a macro definition would be applied to the page calling the
>> macro under any situation.
> 
> I sort of agree, except how else would we provide this functionality?
> Or is it actually the case that it doesn't make sense for a macro to
> control these headers –– I suspect it is.
> 
I think it's the case that it doesn't make sense for the macro to
control these headers.  I have never had the expectation that a tag or
header outside of a macro definition would appear in the final rendered
page.

> Plone's answer to this is to have its wrapper template manually write
> out the XML declaration or maybe just the DOCTYPE. That seems kind of
> crude as well.
> 
> \malthe
> ___
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev

-Kevin
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin J. Kalupson


On 3/4/10 2:22 PM, Shane Hathaway wrote:
> Malthe Borch wrote:
>> On 4 March 2010 22:02, Kevin Kalupson  wrote:
>>> I wouldn't expect the the xml headers in a macro template to be applied to 
>>> the
>>> page template being rendered.  It makes no sense to me that an element not
>>> contained within a macro definition would be applied to the page calling the
>>> macro under any situation.
>>
>> I sort of agree, except how else would we provide this functionality?
>> Or is it actually the case that it doesn't make sense for a macro to
>> control these headers –– I suspect it is.
> 
>  From a template developer's POV, it's useful to apply the same XML 
> declarations throughout a site using metal. 

In that case, there should be macro explicitly containing the doctype
and other wanted headers.

 The current syntax is
> non-obvious and perhaps problematic, but workable.  Some other syntax 
> might be better, but let's not break the current syntax in the 1.1 branch.
> 
I don't think it's a syntax issue, I think it's a behavioral issue.  I
think the 1.1 branch exhibits broken behavior.
> Shane
> 
> ___
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev

-Kevin
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Malthe Borch
On 4 March 2010 22:45, Kevin J. Kalupson  wrote:
> In that case, there should be macro explicitly containing the doctype
> and other wanted headers.

Yes, but that's unfortunately impossible.

> I don't think it's a syntax issue, I think it's a behavioral issue.  I
> think the 1.1 branch exhibits broken behavior.

But keep in mind that we're mimicking ``zope.pagetemplate``. Most
people expect high corcordance.

I just don't know about this. There's a work-around for you though: if
you don't define the macro as the root node, then you won't get the
doctype.

\malthe
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Shane Hathaway
Kevin J. Kalupson wrote:
> 
> On 3/4/10 2:22 PM, Shane Hathaway wrote:
>  The current syntax is
>> non-obvious and perhaps problematic, but workable.  Some other syntax 
>> might be better, but let's not break the current syntax in the 1.1 branch.
>>
> I don't think it's a syntax issue, I think it's a behavioral issue.  I
> think the 1.1 branch exhibits broken behavior.

I'm pretty sure it was in 1.0 as well.  It's a standard ZPT idiom.

Shane
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Charlie Clark
Am 04.03.2010, 17:38 Uhr, schrieb Jasper Op de Coul :

> I don't have commit rights to the repoze repository but I attached a  
> patch.

Go on, sign up. You know you want to:

http://repoze.org/contributing.html

But I think the contribution agreement is a bit lightweight and should be
beerware at least! ;-)

BTW. Where do website bugs go?

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin J. Kalupson
I just tested in zope2 through the zmi.

standard_template.pt

http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>

  
  The Title
  
  
Hey - this is a test.
  


test.pt
---




http://localhost:8080/test.pt - source rendered
---

  

   

  
  
Hey - this is a test.

  


-Kevin


On 3/4/10 2:50 PM, Shane Hathaway wrote:
> Kevin J. Kalupson wrote:
>>
>> On 3/4/10 2:22 PM, Shane Hathaway wrote:
>>  The current syntax is
>>> non-obvious and perhaps problematic, but workable.  Some other syntax
>>> might be better, but let's not break the current syntax in the 1.1
>>> branch.
>>>
>> I don't think it's a syntax issue, I think it's a behavioral issue.  I
>> think the 1.1 branch exhibits broken behavior.
> 
> I'm pretty sure it was in 1.0 as well.  It's a standard ZPT idiom.
> 
> Shane
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin J. Kalupson


On 3/4/10 2:50 PM, Malthe Borch wrote:
> On 4 March 2010 22:45, Kevin J. Kalupson  wrote:
>> In that case, there should be macro explicitly containing the doctype
>> and other wanted headers.
> 
> Yes, but that's unfortunately impossible.
> 
not impossible:
standard_template.pt
-

http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>


 
   The Title
  
  
Hey - this is a test.
  


test.pt
---




localhost:8080/test.pt - rendered source

http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>


  

   

  
  
Hey - this is a test.

  

> I don't think it's a syntax issue, I think it's a behavioral issue.  I
>> think the 1.1 branch exhibits broken behavior.
> 
> But keep in mind that we're mimicking ``zope.pagetemplate``. Most
> people expect high corcordance.
> 
> I just don't know about this. There's a work-around for you though: if
> you don't define the macro as the root node, then you won't get the
> doctype.
> 
> \malthe

-Kevin
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Shane Hathaway
Kevin J. Kalupson wrote:
> I just tested in zope2 through the zmi.

I seem to recall that this syntax works in Plone.  I don't care whether 
it works in plain Zope 2.

Is this really important to you?  While it's a special case, I think 
it's a case of practicality beats purity.  I use it a lot.

Shane

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Shane Hathaway
Kevin Kalupson wrote:
> The importance to me is that there isn't a regression to the duplicate
> xml headers when templates render.  I like to validate my templates as I
> go and not have to hack them to then test my rendered template.

Good point.  If you're statically validating all templates, then putting 
the doctype in every template is a good thing.  However, if you're not 
statically validating, then putting the doctype in every template is 
hazardous, because it's easy to forget, and if you forget, the browser 
quietly slips into quirks mode, causing insidious little CSS bugs.

The moral: I guess static template validation would have saved me those 
hours I spent debugging CSS this week, and maybe putting the doctype in 
the main template has more cons than pros.

Shane

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-04 Thread Kevin J. Kalupson
Shane,

Sorry about sending from the wrong email address - thanks for grabbing
the relevant bit and putting it back in the thread.

On 3/4/10 9:47 PM, Shane Hathaway wrote:
> Kevin Kalupson wrote:
>> The importance to me is that there isn't a regression to the duplicate
>> xml headers when templates render.  I like to validate my templates as I
>> go and not have to hack them to then test my rendered template.
> 
> Good point.  If you're statically validating all templates, then putting
> the doctype in every template is a good thing.

I think that this is the way to go with zpt and is the often forgotten
beauty of zpt.  Because you can do this is what makes it better than a
lot of other templating languages out there.

However, if you're not
> statically validating, then putting the doctype in every template is
> hazardous, because it's easy to forget, and if you forget, the browser
> quietly slips into quirks mode, causing insidious little CSS bugs.
> 
> The moral: I guess static template validation would have saved me those
> hours I spent debugging CSS this week, and maybe putting the doctype in
> the main template has more cons than pros.
> 
> Shane
> 

-Kevin
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue139] Chameleon - can't create xml and doctype declarations from macro

2010-03-14 Thread Malthe Borch
On 4 March 2010 22:22, Shane Hathaway  wrote:
> From a template developer's POV, it's useful to apply the same XML
> declarations throughout a site using metal.  The current syntax is
> non-obvious and perhaps problematic, but workable.  Some other syntax might
> be better, but let's not break the current syntax in the 1.1 branch.

I have now implemented support for the following syntax:

  
...
  

By passing a reference to the actual template instance, it will be
used in its entirety, including any XML declarations.

Please give the current trunk a spin if you have time, to ensure
quality before a release.

\malthe
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev