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

Manlio Perillo manlio_perillo at libero.it
Mon Jul 17 12:15:30 CDT 2006


Manlio Perillo ha scritto:
> Manlio Perillo ha scritto:
>> Valentino Volonghi aka Dialtone ha scritto:
>>> On Sun, 16 Jul 2006 16:18:07 -0200, Manlio Perillo
>>> <manlio_perillo at libero.it> wrote:
>>>
>>> This is off topic here... Twisted-web is the list. 
> 
> I have Cc to twisted-web, hoping this will help the archiving.
> 
> 
> Just for future reference, here is an alternate solution.
> It contains more code, but it is more database friendly
> (and I like this - better performance too?).
> 

Here is another solution:

class Main(rend.Page):
    addSlash = True
    docFactory = loaders.xmlfile('nestedsequence.xhtml')

    def data_control_list(self, ctx, data):
        print "data_control_list"

        return [('a', 'first'),  ('b', 'second')]

    def render_control(self, ctx, data):
        print 'render_control'

        ctx.fillSlots('ctrl_label', data[1])
        ctx.fillSlots('ctrl_name', data[0])

        option_list = [('1', 'uno'), ('2', 'due')]
        ctx.remember(option_list, inevow.IData)

        return ctx.tag

    def render_option(self, ctx, data):
        ctx.fillSlots('opt_label', data[1])
        ctx.fillSlots('opt_value', data[0])

        return ctx

The template is the same, the only change is
n:render="sequence" instead of
n:render="option_list"
in the <select> element.

However there is a thing the I don't understand:
why render_control is called two times?

In my previous solution, both render_option_list and render_control are
 called two times.



Thanks and regards  Manlio Perillo



More information about the Twisted-web mailing list