X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=engine%2Fcomposite.py;h=49ea0b572fb6ec1a551f59b5439f2b1276fc7db2;hb=b490e035bac3b74b66130548f5a4bf4a30ad8375;hp=cd653f8d50375a95c7e214cc577821ba1d36c58b;hpb=d09a7cda398c7ed6ce7cb11155413f66fe82f149;p=myslice.git diff --git a/engine/composite.py b/engine/composite.py index cd653f8d..49ea0b57 100644 --- a/engine/composite.py +++ b/engine/composite.py @@ -2,23 +2,30 @@ from engine.plugin import Plugin class Composite (Plugin): - def __init__ (self, sons=[], *args, **kwds): + def __init__ (self, sons=[], active=None, *args, **kwds): Plugin.__init__ (self, *args, **kwds) self.sons=sons + self.active=active def insert (self, plugin): self.sons.append(plugin) - def render_env (self, request): + # xxx currently there is no guarantee that exactly one son will be active + def template_env (self, request): # this is designed so as to support a template like # {% for son in sons %} {{ son.rendered }} ... - return { 'sons': + def is_active (son): +# print 'comparing >%s< and >%s<'%(son.domid,self.active) + return son.domid==self.active + ranks=range(len(self.sons)) + env = { 'sons': [ { 'rendered': son.render(request), - 'title': son.title(), - 'uuid': son.uuid} - for son in self.sons ]} + 'rank': rank, + 'active': is_active(son), + 'title': son.title, + 'domid': son.domid, + 'classname': son.classname, + } + for (son,rank) in zip(self.sons,ranks) ]} + return env - # xxx need a way to select an active son, like e.g. - # Composite (active='some string') - # and we could then try to find that string in either title or uuid or some other place - # in which case the corresponding 'son' entry in render_env above would son.active=True