I found a way to hack around it.  It's definitely ugly, though.

Basically, I have a python script that calls page templates and
buffers the results as it writes out to REQUEST.RESPONSE.  Each page
template is *just a portion* of my final output XML file.  Since all
of the scripts and templates that I'm using are read from the
filesystem, they are the filesystem-equivalents to the ZODB-stored
objects.

Specifically, I discovered that the FSPageTemplate from CMFCore will
set the content_type attribute on the object to 'text/xml' if the file
begins with '<?xml'.  Otherwise, when it sees the xml-or-html-looking
content, it assumes a content_type of 'text/html', which lowercases
all the tags.

So I added an xml header to all of my page templates, and I strip it
back out inside the python script that calls the template (so that I
don't have the XML header repeated over and over in my final output
XML file).  Ugly, yes, but it does work.

fm

On 10/26/05, Fred Drake <[EMAIL PROTECTED]> wrote:
> On 10/26/05, Floyd May <[EMAIL PROTECTED]> wrote:
> > It appears as though this problem is due to the content-type being set
> > inappropriately (probably text/html).  I'm attempting to render XML,
> > but each of the templates only contains a piece of my final output XML
> > file; therefore, I don't have the '<?xml ... ?>' header in the file.
> > From a perusal of the source for FSPageTemplate, this appears to be
> > the only way to get the Content-Type set to 'text/xml'.  Basically,
>
> Unfortunately, that's true for the current code.  Julien Anguenot and
> I started working on this problem (along with some other aspects of
> the XML vs. HTML behavior) based on the Zope 3 implementation for page
> templates.  The work isn't done yet, though the aspect you're
> interested in is pretty straightforward.
>
> That's only for the Zope 3 version of the code, however.  For now,
> your best bet may be to subclass the PageTemplateFile class (or
> whichever derived class of that that's relevant to you) and override
> the _cook_check() method to do what you need it to do.  If you're
> using a file-system view, you likely need to arrange for your new
> class to be used for some new filename extension; I'm not sure how to
> arrange for that.
>
>
>   -Fred
>
> --
> Fred L. Drake, Jr.    <fdrake at gmail.com>
> "Society attacks early, when the individual is helpless." --B.F. Skinner
>
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to