[Twisted-web] fragments with child lookup

Markus Schiltknecht markus at bluegap.ch
Sun Sep 24 05:19:37 CDT 2006


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.

> 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.

> As I told you the first time you should use a dictionary that contains 
> fragments, in fact that's exactly what you should do.

I know. But, sorry if this seems stubborn, I still don't understand how 
a dictionary of fragments would solve my need to have hierarchically 
organized fragments.

> What you are trying to do is far less dynamic than what you tried to 
> explain.

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.

> 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.

> if you only want to change the outer parts of a page then use the macro 
> system (it is _static_ and request agnostic, it's compiled at the first 
> request but has no connection with it (and it's wrong to act in that way).
> Use a single macro.html template in your application and write 
> everything else in order to fill the macro slots, when you need to 
> change the macro change it (the macro template is the docFactory of the 
> base Page class, when the rest inherits it will fill the content macro 
> (or sidebar or whatever macro) with its own template that statically 
> depends on the page you are writing in that moment.

Macros seem far to static and I don't see how they could solve my 
problem neither.

I'll keep trying, as I don't believe nevow is unable to do that.



More information about the Twisted-web mailing list