X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=unfold%2Fcomposite.py;h=39be5240ae0490185ddf15770ee9e3b460122ac7;hb=92620bf17c60377b7d156a6edf2c6a3077dd2745;hp=77875510fcb124704f6d71f2ca0242543ad10ffb;hpb=8e18c9ff4a961c70f897ca3915959d2fa3f7fb38;p=myslice.git diff --git a/unfold/composite.py b/unfold/composite.py index 77875510..39be5240 100644 --- a/unfold/composite.py +++ b/unfold/composite.py @@ -1,7 +1,7 @@ -from __future__ import print_function - from unfold.plugin import Plugin +from myslice.settings import logger + class Composite (Plugin): """a simple base class for plugins that contain/arrange a set of other plugins @@ -13,17 +13,17 @@ if a valid active_domid is not provided def __init__ (self, sons=None, active_domid=None, *args, **kwds): Plugin.__init__ (self, *args, **kwds) - self.sons= sons if sons else [] - self.active_domid=active_domid + self.sons = sons if sons else [] + self.active_domid = active_domid # make sure this is valid, unset otherwise, so we always have exactly one active self.check_active_domid() def check_active_domid(self): matches= [ son for son in self.sons if son.domid==self.active_domid ] if len(matches)!=1: - print("WARNING: %s has %d valid son(s) for being active - expecting 1, resetting"%\ - (self,len(matches))) - self.active_domid=None + logger.warning("WARNING: {} has {} valid son(s) for being active - expecting 1, resetting"\ + .format(self,len(matches))) + self.active_domid = None def insert (self, plugin): self.sons.append(plugin) @@ -33,9 +33,10 @@ if a valid active_domid is not provided # {% for son in sons %} {{ son.rendered }} ... def is_active (son,rank): # if active_domid is not specified, make the first one active - if not self.active_domid: return rank==0 - return son.domid==self.active_domid - ranks=range(len(self.sons)) + if not self.active_domid: + return rank==0 + return son.domid == self.active_domid + ranks = range(len(self.sons)) env = { 'sons': [ { 'rendered': son.render(request), 'rank': rank,