[Twisted-web] [Nevow] template performance

Jean-Paul Calderone exarkun at divmod.com
Fri Dec 15 09:28:31 CST 2006


On Fri, 15 Dec 2006 16:11:46 +0100, Manlio Perillo <manlio_perillo at libero.it> wrote:
>Jean-Paul Calderone ha scritto:
>>On Fri, 15 Dec 2006 15:43:44 +0100, Manlio Perillo 
>><manlio_perillo at libero.it> wrote:
>>>Jean-Paul Calderone ha scritto:
>>>>On Fri, 15 Dec 2006 11:56:55 +0100, Manlio Perillo 
>>>><manlio_perillo at libero.it> wrote:
>>>>[...]
>>>>>Is it possible to use that same model used by django.template?
>>>>>
>>>>>You pass a context (that is a dictionary usable like a stack: push/pop) 
>>>>>to the render function.
>>>>>All the data directive will search the data in the context (like djando, 
>>>>>first dictionary lookup, then attribute lookup, and so).
>>>>>
>>>>>As an example n:data='x.y' ==> ctx['x']['y'].
>>>>>A rend.Page.renderHTTP can build a context from the instance dictionary.
>>>>
>>>>Optimization can be a complicated undertaking.
>>>
>>>I'm not asking for optimization.
>>
>>You are.  You pointed out something which you thought was slow.
>
>Well, its a fact (unless my tests are wrong).

I didn't say it wasn't.

>>You
>>suggested a different way to accomplish something much the same.
>
>I'm not sure if it will be the same.

It's a means of passing objects to different parts of Python code
responsible for rendering a template.  That's what the existing
context code is for.  They're basically the same thing.

>>You
>>place greater value on one than the other because of performance reasons.
>>That's what "optimization" means.
>>>I'm asking for a possible rewriting of how rend.Page (and flat) works.
>>
>>The context is being removed, so that will happen.
>
>Ok, but how is going this branch of development?

It's not really going anywhere at the moment, presumably because
everyone has more important things to work on.

>>Since the way you
>>described continues to expose the context as an application level API,
>>I don't think that is how the rewrite will go.
>
>I'm talking about a different context.

Um, okay.

>A context that holds data.

I don't know what that means.  I don't think you can put anything
except data into a data structure.

>
>context = {'table': ..., 'header': ..., 'request': request}
>return flat.flatten(node, context)
>
>
>Now stan use object adaptation (locate/remember) for obtaing the data 
>requested by a data directive.
>

There will be no context nor any locate or remember methods in the
rewritten system.  They are a bad idea, completely independent from
performance concerns.

Jean-Paul



More information about the Twisted-web mailing list