[Twisted-web] fragments with child lookup

Valentino Volonghi aka Dialtone dialtone at divmod.com
Mon Sep 25 06:31:30 CDT 2006

On Mon, 25 Sep 2006 12:51:41 +0200, Markus Schiltknecht <markus at bluegap.ch> wrote:
><div nevow:render="content_-1">  probably won't work...
>To be able to do it that way, I would have to stuff the dictionaries with 
>fragments into an array with levels, i.e.
>fragments_1 = {
>     '_default': loaders.xmlfile('templates/default.html'),
>     'kontakt': loaders.stan(...),
>fragments_2 = {
>     '_default': ..
>     'info': ...
>levels = [fragments_1, fragments_2]
>But even then, I cannot write a common renderer, because how does it tell 
>which fragment to serve, i.e. at what level it currently is.
>def render_content(self, ctx, data):
>     try:
>         fragment_name = inevow.ICurrentSegments(ctx)[???]
>     ...

I don't completely understand why you really really really need this but...

def render_content(self, level):
    def _(ctx, data):
            fragment_name = inevow.ICurrentSegments(ctx)[level]


<nevow:invisible nevow:render="content 1">...</nevow:invisible>

>Sill I'm still surprised, nevow does not provide that functionality.

It's a bit frustrating for me to keep answering while you consistently say
that 'nevow does not provide XXX functionality', can you please stop implying that nevow is a pile of junk compared to others?

>I think another way to look at my problem is: how do I code a pastebin that 
>_can_ be embedded like that? A pastebin which can be a fragment of another 

Using macros of course and it's very easy to do, and the code I showed you already does that and no it's not too static because you can make anything that looks static a lot more dynamic, this is python not C++.

More information about the Twisted-web mailing list