[Twisted-web] Dynamical generated slots

Jean-Paul Calderone exarkun at divmod.com
Thu Nov 24 22:57:29 MST 2005

On Thu, 24 Nov 2005 16:30:58 +0000, Johann Siegele <j.siegele at gmx.at> wrote:
>    im looking for a possibility to generate Slots for a livepage
>my code for the livepage looks like this, it works fine, but i can not
>update any of the slots!

What does "update" mean?  The only operation on slots I know of is "fill" - ie, ctx/proto.fillSlots(slotName, slotValue).

>    def render_mytable(self, ctx, data):
>            mydetail=[]
>            for i in range(1,15):
>              mydetail.append([T.td [T.slot('test'+str(i), "default")]])
>              if i % 3 is 0:

You should not use "is" for integer comparison.  It will be wrong sometimes in confusing ways.  Use "==".

>               mydetail.append([T.tr[T.td['-test-']]],)
>            return ctx.tag[mydetail]

This code doesn't ever seem to fill any slots.  I don't think I understand the question you're asking.

><table nevow:render="mytable" name="mytabletest"/>
>it should be possible that the user can change the text in the row n and
>colume x.
>this do not work:
>client.set('test1', text)

Ah.  Slots are *server* side.  You cannot fill them using LivePage after the page has been rendered.

>i think the problem is, that the slots are not hardcoded.
>is there a other possibility.

Instead, you probably want to give the nodes IDs and address them in that manner.  Also, I would recommend you take a look at Athena, which makes this kind of thing much easier to handle.  Instead of trying to set the values of nodes in the DOM on the client from the server, the client can implement event handlers and adjust the contents of the page accordingly.


More information about the Twisted-web mailing list