[Zope3-dev] Input encoding of a PageTemplateFile

Dmitry Vasiliev lists at hlabs.spb.ru
Fri Jul 22 03:03:11 EDT 2005


Fred Drake wrote:
> On 7/21/05, Dmitry Vasiliev <dima at hlabs.spb.ru> wrote:
> 
>>Log message for revision 37358:
>>  Now input encoding of a PageTemplateFile in 'html' mode is determined
>>  by <meta> declaration and then the declaration will stripped.
>>
>>  Open question:
>>      Shouldn't <meta>/<?xml?> stripping be in PageTemplate.__call__()?
> 
> 
> This should be stripped by the compilation phase.  Since those should
> never be part of the output, they need not be represented in the
> compiled template at all.

I think about the following generic algorithm:

1. Preparation stage. Content type and encoding are determining based on the 
<?xml?>/<meta> declarations. In case of the 'text/html' type and a not unicoded 
content we decode the content. In case of the 'text/xml' type the parser takes 
care of the encoding at the cooking stage. We can do it somewhere inside 
PageTemplate.pt_edit()/PageTemplate.write() methods.

2. Cooking stage. Nothing interested for our case.

3. Rendering stage. Now we can strip the <?xml?>/<meta> declarations. We can do 
it somewhere inside PageTemplate.pt_render()/PageTempalte.__call__() methods.


BTW, just curious why we need to read HTML files in the text mode (See 
PageTemplateFile._read_file())?

-- 
Dmitry Vasiliev (dima at hlabs.spb.ru)
     http://hlabs.spb.ru


More information about the Zope3-dev mailing list