Hi all,

Le vendredi 24 avril 2015 10:17:15 UTC+2, Bertrand Croq a écrit :
>
> Le jeudi 23 avril 2015, 10:47:52 Terrence Brannon a écrit : 
> > 
> > On Thursday, April 23, 2015 at 7:03:05 AM UTC-7, Bertrand Croq wrote: 
> > > 
> > > You may find other solutions in this blog entry: 
> > > 
> http://www.nagare.org/trac/blog/html-structuration-inheritance-aggregation 
>

A warning though:

Creating ``Component`` instances in views is discouraged now since 
callbacks on the components created this way won't be retained.
I don't think we should keep the blog post as is, i.e. with this practice.
@nagare-users: what do you think?

 

> > > 
> > 
> > I'm sorry, but I dont quite understand this code 
> > 
> > class EntryTemplate(object): 
> >     def __init__(self, entry): 
> >         self.entry = entry 
> > @render_for(EntryTemplate) 
> > def EntryTemplate(self, h, *args): 
> >     """ 
> >     Same code that we used in ``render_BaseEntry`` 
> >     but using ``self.entry`` instead of ``self``. 
> >     """ 
> >     with h.div(class_='entry'): 
> >         with h.div(class_='title'): 
> >             h << self.entry.render(h, model='title') 
> >         with h.div(class_='properties'): 
> >             h << self.entry.render(h, model='properties') 
> >     return h.root 
> > 
> > 1. Why does the decorated rendering method have the same name as the 
> > class? 
>
> It is a typo. The rendering method should be named 
> "render_entry_template". 
>
>
> > 2. Does the name of the decorated rendering method matter? 
>
> The name doesn't really matter but it is a good idea to give them a name 
> that indicated what it renders. Personnaly, I now use this kind of 
> convention: 
>
> @render_for(MyClass, 'this_model') 
> def render_my_class__this_model(...) 
>
>
> > 3. How does the slot `entry` in the plain Python object become a 
> > component?   
>
> In the "render_SimpleEntry_header" method you can see that EntryTemplate 
> receives a Component instance because we use "EntryTemplate(comp)" instead 
> of "EntryTemplate(self)"  


>
> Regards, 
> -- 
> Bertrand CROQ 
> 02 23 21 21 50 
>
> Net-ng 
> 6, rue de Jouanet 
> 35700 RENNES 
> http://www.net-ng.com 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Nagare users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nagare-users+unsubscr...@googlegroups.com.
To post to this group, send email to nagare-users@googlegroups.com.
Visit this group at http://groups.google.com/group/nagare-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to