[Twisted-web] Re: [Twisted-Python] again on nested sequence

Valentino Volonghi aka Dialtone dialtone at divmod.com
Mon Jul 17 12:41:09 CDT 2006


On Mon, 17 Jul 2006 15:18:13 -0200, Manlio Perillo <manlio_perillo at libero.it> wrote:
>>     def render_option_list(self, ctx, data):
>>         option_list = [('1', 'uno'), ('2', 'due')]
>>         tag = ctx.tag
>>
>>         pattern = inevow.IQ(ctx).patternGenerator("item")
>>         content = [pattern(data=option) for option in option_list]
>>
>>         return ctx.tag.clear()[content]

>This is very strange.

Not that much.

>In my real application (that should be equivalent to this one, only
>names changes), the whole <option> node is ignored!

Because you are never calling it. inevow.IQ(tag).patternGenerator('item') is
a much better way to get the pattern item.

Also the renderer you just wrote is basically the sequence renderer except not generic and fairly marginally faster if at all. Is there any valid reason for not using a better initial data structure to avoid rewriting the sequence renderer losing the reusability?

>I can't understand why.

Don't use the context so intensely if you want to avoid weird things, 
understanding it takes considerable effort. The only thing the context is really still useful for is retrieving the tag and the request. Everything else can be done with one of those 2 things.






More information about the Twisted-web mailing list