[Twisted-web] fragments with child lookup
Valentino Volonghi aka Dialtone
dialtone at divmod.com
Sun Sep 24 14:43:20 CDT 2006
On Sun, 24 Sep 2006 12:19:37 +0200, Markus Schiltknecht <markus at bluegap.ch> wrote:
>Valentino Volonghi aka Dialtone wrote:
>>You can't do that because pastebin is not designed to be used in that way.
>You mean, even though pastebin's RootPage is derived from a Fragment, I
>can't embed it into another Page? This would mean nevow is not component
>based, according to my understanding at least. I can't believe that.
No it means another thing. It means that the RootPage contains information on the children of that page and rendering that as a Fragment will lose this information. This means that the pastebin is not embeddable (which is what I said) and it should also be clear to you (I already tried to explain this and also exarkun did now) that a Page should not be used as a Fragment and it's also wrong to ask a Fragment about its Page children of course.
>>Otherwise simply return the root page of the pastebin from the
>>child_pastebin method of the root page of your site.
>That does the URL-space-embedding of the pastebin into another page. But not
>the design wise embedding.
That does what the pastebin can do at most. If it's not designed to be embedded than you cannot embed it, simple.
>Why? I still didn't encounter an example in nevow with fragments containing
>other fragments, deciding which child-fragment to show based on the URL.
That's because nobody ever encountered this usecase, which might mean that what you are trying to do is done in a different way in Nevow or that you are tring to use Nevow in a new way.
But anyway there is only ONE segment that is used by the fragment and thus the ONE segment can be used as a key in a dictionary that contains some Fragments, here is how you can solve this problem. Also if you name you templates in the same way you use for the segment then you can also make this even more dynamic and easy to write.
>>Just pass the docFactory argument to the Page class when you create it and
>>let the Fragments render themselves with the appropriate template (when the
>>are needed, and they are not strictly here).
>That does not solve my problem.
IMHO it does and fairly well, you might not have completely grasped nevow or I may not have completely understood your usecase.
>Macros seem far to static and I don't see how they could solve my problem
They are not too static.
>I'll keep trying, as I don't believe nevow is unable to do that.
I think you are trying to use nevow in the same way you use other frameworks which unfortunately doesn't work at all.
More information about the Twisted-web