incubator-bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matevz Bradac <mate...@gmail.com>
Subject Re: Genshi XHTML + HTML 5
Date Sat, 01 Dec 2012 16:16:46 GMT
Thanks for the suggestion, but unfortunately it won't work on the
instance level. =/
The Stream class is using __slots__, so most instance attributes are
read-only, e.g. this:
    import types
    stream.render = types.MethodType(new_render, stream)
doesn't work - AttributeError exception.

Brane suggested monkeypatching on a class/module level, so maybe
genshi.core.Stream.serialize(),
or even genshi.output.get_serializer() would be good candidates.

--
matevzb


On Fri, Nov 30, 2012 at 7:49 AM, Olemis Lang <olemis@gmail.com> wrote:
> On 11/29/12, Olemis Lang <olemis@gmail.com> wrote:
>> On 11/29/12, Olemis Lang <olemis@gmail.com> wrote:
>>> On 11/29/12, Matevz Bradac <matevzb@gmail.com> wrote:
>>>> Hi,
>>>>
>>>
>>> :)
>>>
> [...]
>>
>> I suggest you to consider this approach
>>
>> 1. BH theme already implements IRequestFilter
>> 2. implement a stream wrapper overriding render
>>     method in such a way that DocType.HTML5
>>     (or something more accurate , your choice ;)
>>     is used instead of HTML strict *if appropriate*
>>     e.g. bloodhound theme enabled , etc, etc ...
>
> ... and an elegant solution without wrappers consists of overriding
> access to class' render method using instance attribute , like this
>
> {{{
> #!py
>
> new_doctype = DocType.HTML5
>
> def new_render(method, doctype, out, encoding, [...] ):
>     return stream.render(method, doctype=new_doctype, out=out,
>                            encoding=encoding)
>
> stream.render = new_render
>
> [...]
>
> }}}
>
> [...]
>
> --
> Regards,
>
> Olemis.
>
> Blog ES: http://simelo-es.blogspot.com/
> Blog EN: http://simelo-en.blogspot.com/
>
> Featured article:

Mime
View raw message