X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=engine%2Fcomposite.py;h=6d6ceeca17381a528dbf347664d17762a0385919;hb=6373f4c6f48b4a2e049372ad6c6dd4adf9c95b69;hp=69953f709eefd126e3a52ab9df21c61e3d7de3ff;hpb=36affe7c738e94c6085f50b5fae8dfb9ae9b81fd;p=unfold.git diff --git a/engine/composite.py b/engine/composite.py index 69953f70..6d6ceeca 100644 --- a/engine/composite.py +++ b/engine/composite.py @@ -2,26 +2,31 @@ 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) + # 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 }} ... + def is_active (son): +# print 'comparing >%s< and >%s<'%(son.domid,self.active) + return son.domid==self.active ranks=range(len(self.sons)) - return { 'sons': + env = { 'sons': [ { 'rendered': son.render(request), + 'rank': rank, + 'active': is_active(son), + # this should probably come from son._settings.. 'title': son.title, - 'uuid': son.uuid, + 'domid': son.domid, 'classname': son.classname, - 'rank': rank} + } 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 template_env above would son.active=True