Index: quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py
===================================================================
--- quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py	(revision 3029)
+++ quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py	(revision 3169)
@@ -14,12 +14,14 @@
 except ImportError:
     "Before plon4 we don't have an annotation storage for settings."
-    IPortletAssignmentSettings = lambda assignment:{}
+    IPortletAssignmentSettings = lambda assignment: {}
 
 from GChartWrapper import VerticalBarStack
 
 from quintagroup.analytics.config import COLORS, OTHER_TYPES, NO_WF_BIND
+
 
 class OwnershipByType(BrowserView):
     MAX = 10
+
     def __init__(self, context, request):
         self.context = context
@@ -87,16 +89,17 @@
         for type_ in types:
             data.append(self.getContent(type_))
-        other = [self.getContent(t) for t in self.getTypes(all=True)[self.MAX:]]
+        other = [self.getContent(t) for t in self.getTypes(
+                                                    all=True)[self.MAX:]]
         if other:
             data.append([sum(l) for l in zip(*other)])
         max_value = max(self.getTotal())
         chart = VerticalBarStack(data, encoding='text')
-        types = other and types+OTHER_TYPES or types
+        types = other and types + OTHER_TYPES or types
         chart.title('Content ownership by type').legend(*(types))
         chart.bar('a', 10, 0).legend_pos("b")
         chart.color(*COLORS)
-        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users)
+        chart.size(800, 375).scale(0, max_value).axes('xy').label(*self.users)
         chart.axes.type("y")
-        chart.axes.range(0,0,max_value)
+        chart.axes.range(0, 0, max_value)
         return chart.img()
 
@@ -104,4 +107,5 @@
 class OwnershipByState(BrowserView):
     MAX = 10
+
     def __init__(self, context, request):
         self.context = context
@@ -160,5 +164,6 @@
                     data.append(l)
             if len(data) > 0:
-                self.data[NO_WF_BIND] = map(lambda t,d:t-d, self.data[NO_WF_BIND], data)
+                self.data[NO_WF_BIND] = map(lambda t, d: t - d,
+                                            self.data[NO_WF_BIND], data)
         return self.data[type_]
 
@@ -181,10 +186,11 @@
         max_value = max(self.getTotal())
         chart = VerticalBarStack(data, encoding='text')
-        chart.title('Content ownership by state').legend(*self.states+[NO_WF_BIND])
+        title = 'Content ownership by state'
+        chart.title(title).legend(*self.states + [NO_WF_BIND])
         chart.bar('a', 10, 0).legend_pos("b")
         chart.color(*COLORS)
-        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users)
+        chart.size(800, 375).scale(0, max_value).axes('xy').label(*self.users)
         chart.axes.type("y")
-        chart.axes.range(0,0,max_value)
+        chart.axes.range(0, 0, max_value)
         return chart.img()
 
@@ -192,4 +198,5 @@
 class TypeByState(BrowserView):
     MAX = 10
+
     def __init__(self, context, request):
         self.context = context
@@ -249,5 +256,6 @@
                     data.append(l)
             if len(data) > 0:
-                self.data[NO_WF_BIND] = map(lambda t,d:t-d, self.data[NO_WF_BIND], data)
+                self.data[NO_WF_BIND] = map(lambda t, d: t - d,
+                                            self.data[NO_WF_BIND], data)
         return self.data[state]
 
@@ -270,10 +278,11 @@
         max_value = max(self.getTotal())
         chart = VerticalBarStack(data, encoding='text')
-        chart.title('Content type by state').legend(*self.states+[NO_WF_BIND])
+        chart.title('Content type by state').legend(
+            *self.states + [NO_WF_BIND])
         chart.bar('a', 10, 0).legend_pos("b")
         chart.color(*COLORS)
-        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.types)
+        chart.size(800, 375).scale(0, max_value).axes('xy').label(*self.types)
         chart.axes.type("y")
-        chart.axes.range(0,0,max_value)
+        chart.axes.range(0, 0, max_value)
         return chart.img()
 
@@ -300,15 +309,18 @@
             if obj.hasProperty('left_slots'):
                 info['left_slots'] = obj.getProperty('left_slots')
-                self.expressions = self.expressions.union(set(info['left_slots']))
+                self.expressions = self.expressions.union(
+                                            set(info['left_slots']))
             if obj.hasProperty('right_slots'):
                 info['right_slots'] = obj.getProperty('right_slots')
-                self.expressions = self.expressions.union(set(info['right_slots']))
+                self.expressions = self.expressions.union(
+                                            set(info['right_slots']))
         return info
 
     def _walk(self, obj, level=-1):
         yield self._getInfo(obj)
-        if level != 0 and (IFolderish.providedBy(obj) or IBaseFolder.providedBy(obj)):
+        if level != 0 and (IFolderish.providedBy(obj) \
+                       or IBaseFolder.providedBy(obj)):
             for v in obj.contentValues():
-                for i in self._walk(v, level-1):
+                for i in self._walk(v, level - 1):
                     yield i
 
@@ -321,5 +333,6 @@
         infos = []
         for i in self._walk(self.context, level):
-            if self.DEBUG or i['left_slots'] is not None or i['right_slots'] is not None:
+            if self.DEBUG or i['left_slots'] is not None \
+                          or i['right_slots'] is not None:
                 infos.append(i)
         self.total = len(infos)
@@ -341,4 +354,5 @@
         return exprs
 
+
 class PropertiesStats(BrowserView):
     def __init__(self, context, request):
@@ -362,5 +376,6 @@
         if IPropertyManager.providedBy(obj):
             obj = aq_base(obj)
-            self.proplist.extend([i for i in obj.propertyIds() if i not in self.proplist])
+            self.proplist.extend(
+                    [i for i in obj.propertyIds() if i not in self.proplist])
             if obj.hasProperty(self.propname):
                 info['slots'] = obj.getProperty(self.propname)
@@ -368,14 +383,17 @@
                     info['slots'] = str(info['slots'])
                 if not isinstance(info['slots'], basestring):
-                    self.expressions = self.expressions.union(set(info['slots']))
-                else:
-                    self.expressions = self.expressions.union(set([info['slots']]))
+                    self.expressions = self.expressions.union(
+                                                set(info['slots']))
+                else:
+                    self.expressions = self.expressions.union(
+                                                set([info['slots']]))
         return info
 
     def _walk(self, obj, level=-1):
         yield self._getInfo(obj)
-        if level != 0 and (IFolderish.providedBy(obj) or IBaseFolder.providedBy(obj)):
+        if level != 0 and (IFolderish.providedBy(obj) \
+                       or IBaseFolder.providedBy(obj)):
             for v in obj.contentValues():
-                for i in self._walk(v, level-1):
+                for i in self._walk(v, level - 1):
                     yield i
 
@@ -405,4 +423,5 @@
         return exprs
 
+
 class PortletsStats(BrowserView):
     def __init__(self, context, request):
@@ -416,28 +435,40 @@
 
     def getAssignmentMappingUrl(self, context, manager):
-        baseUrl = str(getMultiAdapter((context, self.request), name='absolute_url'))
+        baseUrl = str(getMultiAdapter((context, self.request),
+                                      name='absolute_url'))
         return '%s/++contextportlets++%s' % (baseUrl, manager.__name__)
 
     def getAssignmentsForManager(self, context, manager):
-        assignments = getMultiAdapter((context, manager), IPortletAssignmentMapping)
+        assignments = getMultiAdapter((context, manager),
+                                      IPortletAssignmentMapping)
         return assignments.values()
 
     def getPortletsMapping(self, context):
-        leftcolumn = getUtility(IPortletManager, name=u'plone.leftcolumn', context=context)
-        rightcolumn = getUtility(IPortletManager, name=u'plone.rightcolumn', context=context)
-        leftmapping = getMultiAdapter((context, leftcolumn,), IPortletAssignmentMapping)
-        rightmapping = getMultiAdapter((context, rightcolumn,), IPortletAssignmentMapping)
+        leftcolumn = getUtility(IPortletManager, name=u'plone.leftcolumn',
+                                context=context)
+        rightcolumn = getUtility(IPortletManager, name=u'plone.rightcolumn',
+                                 context=context)
+        leftmapping = getMultiAdapter((context, leftcolumn,),
+                                      IPortletAssignmentMapping)
+        rightmapping = getMultiAdapter((context, rightcolumn,),
+                                       IPortletAssignmentMapping)
         return (leftmapping, rightmapping)
 
     def getLocalPortletsManager(self, context):
-        leftcolumn = getUtility(IPortletManager, name='plone.leftcolumn', context=context)
-        rightcolumn = getUtility(IPortletManager, name='plone.rightcolumn', context=context)
-        leftmanager = getMultiAdapter((context, leftcolumn,), ILocalPortletAssignmentManager)
-        rightmanager = getMultiAdapter((context, rightcolumn,), ILocalPortletAssignmentManager)
+        leftcolumn = getUtility(IPortletManager, name='plone.leftcolumn',
+                                context=context)
+        rightcolumn = getUtility(IPortletManager, name='plone.rightcolumn',
+                                 context=context)
+        leftmanager = getMultiAdapter((context, leftcolumn,),
+                                      ILocalPortletAssignmentManager)
+        rightmanager = getMultiAdapter((context, rightcolumn,),
+                                       ILocalPortletAssignmentManager)
         return (leftmanager, rightmanager)
 
     def getPortletsManager(self, context):
-        left = getUtility(IPortletManager, name='plone.leftcolumn', context=context)
-        right = getUtility(IPortletManager, name='plone.rightcolumn', context=context)
+        left = getUtility(IPortletManager, name='plone.leftcolumn',
+                          context=context)
+        right = getUtility(IPortletManager, name='plone.rightcolumn',
+                           context=context)
         return (left, right)
 
@@ -458,7 +489,7 @@
 
             data.append({
-                'title'      : assignments[idx].title,
-                'editview'   : editviewName,
-                'visible'    : settings.get('visible', True),
+                'title': assignments[idx].title,
+                'editview': editviewName,
+                'visible': settings.get('visible', True),
                 })
         return data
@@ -481,5 +512,5 @@
         #leftmanager, rightmanager = self.getLocalPortletsManager(obj)
         #info['left_slots'] = self.getPortlets(obj, leftmapping, leftmanager)
-        #info['right_slots'] = self.getPortlets(obj, rightmapping, rightmanager)
+        #info['right_slots'] = self.getPortlets(obj, rightmapping,rightmanager)
         lass = self.getAssignmentsForManager(obj, left)
         rass = self.getAssignmentsForManager(obj, right)
@@ -489,6 +520,6 @@
         prass = self.portlets_for_assignments(rass, right, rurl)
         #print obj, plass, prass
-        info['left_slots'] = plass #[i['title'] for i in plass]
-        info['right_slots'] = prass #[i['title'] for i in prass]
+        info['left_slots'] = plass  # [i['title'] for i in plass]
+        info['right_slots'] = prass  # [i['title'] for i in prass]
         return info
 
@@ -498,7 +529,8 @@
         except:
             pass
-        if level != 0 and (IFolderish.providedBy(obj) or IBaseFolder.providedBy(obj)):
+        if level != 0 and (IFolderish.providedBy(obj) \
+                       or IBaseFolder.providedBy(obj)):
             for v in obj.contentValues():
-                for i in self._walk(v, level-1):
+                for i in self._walk(v, level - 1):
                     yield i
 
@@ -511,5 +543,6 @@
         infos = []
         for i in self._walk(self.context, level):
-            if self.DEBUG or i['left_slots'] is not None or i['right_slots'] is not None:
+            if self.DEBUG or i['left_slots'] is not None \
+                          or i['right_slots'] is not None:
                 infos.append(i)
         self.total = len(infos)
