[Twisted-web] [Nevow] template performance

Manlio Perillo manlio_perillo at libero.it
Fri Dec 15 11:56:21 CST 2006


Jean-Paul Calderone ha scritto:
> On Fri, 15 Dec 2006 18:11:11 +0100, Manlio Perillo 
> <manlio_perillo at libero.it> wrote:
>> Jean-Paul Calderone ha scritto:
>>> On Fri, 15 Dec 2006 17:22:46 +0100, Manlio Perillo [...]
>>>>
>>>> Wait.
>>>> Does this means that I can no more render a table with the sequence 
>>>> renderer?
>>>
>>> Most likely it does not mean this.
>>
>> Please, let me understand.
>> How will I (and I should now) render a table using as much XHML code 
>> as possible?
>>
> 
> Maybe like this:
> 
> http://twistedmatrix.com/trac/browser/sandbox/exarkun/merit/trunk/merit/resourceweb.py?rev=18554#L131 
> 


Ok, thanks.
There are some useful patterns.
It's very unfortunate that this things are not well documented.


> 
> I have not explored much further than that yet.  If you have any
> suggestions, feel free to make them.
> 

I don't (still) know if this will be really useful, but I would like to 
have something like:

class MyPage(page.Element):
    def __init(self):
        self.x = {'y': 1}
        self.x = data(self.x)


<p n:render="string" n:data="x.y" />  ==>
<p>1</p>


For the sequence renderer, the solution used by Django is to "push" the 
loop variable into the context (used as a stack).
The problem is that in Nevow template we can not name this variable.

This means that one have to do:
<ul n:render="sequence" n:data="list">
    <li n:data="@sequence" n:render="string" />
</ul>



Regards  Manlio Perillo



More information about the Twisted-web mailing list