rename render_env -> template_env
[myslice.git] / engine / composite.py
1 from engine.plugin import Plugin
2
3 class Composite (Plugin):
4
5     def __init__ (self, sons=[], *args, **kwds):
6         Plugin.__init__ (self, *args, **kwds)
7         self.sons=sons
8         
9     def insert (self, plugin):
10         self.sons.append(plugin)
11
12     def template_env (self, request):
13         # this is designed so as to support a template like
14         # {% for son in sons %} {{ son.rendered }} ...
15         return { 'sons': 
16                  [ { 'rendered': son.render(request),
17                      'title': son.title(),
18                      'uuid': son.uuid}
19                    for son in self.sons ]}
20
21     # xxx need a way to select an active son, like e.g.
22     # Composite (active='some string')
23     # and we could then try to find that string in either title or uuid or some other place
24     # in which case the corresponding 'son' entry in template_env above would son.active=True