autopep8
authorArthur Lutz <arthur.lutz@logilab.fr>
Tue, 17 Jan 2017 11:55:41 +0100
changeset 368 f807b073b7d3
parent 367 d269f913a0a6
child 369 6cf39e14ec02
autopep8
__pkginfo__.py
entities.py
hooks.py
migration/1.5.0_Any.py
migration/postcreate.py
schema.py
setup.py
sobjects.py
test/test_blog.py
test/unittest_blog.py
views/__init__.py
views/blog.py
views/boxes.py
views/entry.py
views/urlpublishing.py
--- a/__pkginfo__.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/__pkginfo__.py	Tue Jan 17 11:55:41 2017 +0100
@@ -18,10 +18,10 @@
     'Framework :: CubicWeb',
     'Programming Language :: Python',
     'Programming Language :: JavaScript',
-    ]
+]
 
 __depends__ = {'cubicweb': '>= 3.19.0',
-               'six': '>= 1.4.0',}
+               'six': '>= 1.4.0', }
 __recommends__ = {'cubicweb-tag': None,
                   'cubicweb-preview': None,
                   'cubicweb-comment': '>= 1.6.3',
@@ -40,6 +40,7 @@
 
 THIS_CUBE_DIR = join('share', 'cubicweb', 'cubes', modname)
 
+
 def listdir(dirpath):
     return [join(dirpath, fname) for fname in _listdir(dirpath)
             if fname[0] != '.' and not fname.endswith('.pyc')
@@ -49,7 +50,7 @@
 data_files = [
     # common files
     [THIS_CUBE_DIR, [fname for fname in glob('*.py') if fname != 'setup.py']],
-    ]
+]
 # check for possible extended cube layout
 for dirname in ('entities', 'views', 'sobjects', 'hooks', 'schema',
                 'data', 'i18n', 'migration', 'wdoc'):
--- a/entities.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/entities.py	Tue Jan 17 11:55:41 2017 +0100
@@ -13,6 +13,7 @@
 from cubicweb.view import EntityAdapter
 from cubicweb.predicates import is_instance
 
+
 class BlogIFeedAdapter(EntityAdapter):
     __regid__ = 'IFeed'
     __select__ = is_instance('Blog', 'MicroBlog')
@@ -26,6 +27,7 @@
         return self._cw.build_url(rql=rql % self.entity.eid, vid='rss',
                                   vtitle=self.entity.dc_title())
 
+
 class BlogISiocContainerAdapter(EntityAdapter):
     __regid__ = 'ISIOCContainer'
     __select__ = is_instance('Blog')
@@ -40,7 +42,8 @@
 class BlogEntry(AnyEntity):
     """customized class for BlogEntry entities"""
     __regid__ = 'BlogEntry'
-    fetch_attrs, cw_fetch_order = fetch_config(['creation_date', 'title'], order='DESC')
+    fetch_attrs, cw_fetch_order = fetch_config(
+        ['creation_date', 'title'], order='DESC')
 
     def dc_title(self):
         return self.title
@@ -56,6 +59,7 @@
                 break
         return self._cw.format_date(dc_date, date_format=date_format)
 
+
 class BlogEntryICalendarableAdapter(EntityAdapter):
     __regid__ = 'ICalendarable'
     __select__ = is_instance('BlogEntry')
@@ -104,4 +108,3 @@
     def isioc_topics(self):
         # XXX link to tags, folders?
         return []
-
--- a/hooks.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/hooks.py	Tue Jan 17 11:55:41 2017 +0100
@@ -1,6 +1,7 @@
 from cubicweb.predicates import is_instance, is_in_state
 from cubicweb.sobjects.notification import NotificationView, StatusChangeMixIn
 
+
 class BlogEntryPublishedView(StatusChangeMixIn, NotificationView):
     """get notified from published blogs"""
     __select__ = is_instance('BlogEntry',) & is_in_state('published')
--- a/migration/1.5.0_Any.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/migration/1.5.0_Any.py	Tue Jan 17 11:55:41 2017 +0100
@@ -1,1 +1,2 @@
-change_relation_props('BlogEntry', 'entry_of', 'Blog', commit=True, cardinality='**')
+change_relation_props('BlogEntry', 'entry_of', 'Blog',
+                      commit=True, cardinality='**')
--- a/migration/postcreate.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/migration/postcreate.py	Tue Jan 17 11:55:41 2017 +0100
@@ -13,4 +13,3 @@
 
 publish = bwf.add_transition(_('publish'), draft, published,
                              ('managers', 'owners'))
-
--- a/schema.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/schema.py	Tue Jan 17 11:55:41 2017 +0100
@@ -10,7 +10,9 @@
 class Blog(EntityType):
     title = String(maxsize=50, required=True)
     description = RichString()
-    rss_url = String(maxsize=128, description=_('blog\'s rss url (useful for when using external site such as feedburner)'))
+    rss_url = String(maxsize=128, description=_(
+        'blog\'s rss url (useful for when using external site such as feedburner)'))
+
 
 class BlogEntry(WorkflowableEntityType):
     __permissions__ = {
@@ -18,35 +20,39 @@
         'add': ('managers', 'users'),
         'update': ('managers', 'owners'),
         'delete': ('managers', 'owners')
-        }
+    }
     title = String(required=True, fulltextindexed=True, maxsize=256)
     content = RichString(required=True, fulltextindexed=True)
     entry_of = SubjectRelation('Blog')
     same_as = SubjectRelation('ExternalUri')
 
+
 class MicroBlog(EntityType):
     title = String(maxsize=50, required=True)
     description = RichString()
 
+
 class MicroBlogEntry(EntityType):
     __permissions__ = {
         'read': ('managers', 'users'),
         'add': ('managers', 'users'),
         'update': ('managers', 'owners'),
         'delete': ('managers', 'owners')
-        }
+    }
     content = RichString(required=True, fulltextindexed=True)
     entry_of = SubjectRelation('MicroBlog')
     same_as = SubjectRelation('ExternalUri')
 
+
 class UserAccount(EntityType):
-    name = String(required=True) # see foaf:accountName
+    name = String(required=True)  # see foaf:accountName
+
 
 class has_creator(RelationDefinition):
     subject = ('BlogEntry', 'MicroBlogEntry')
     object = 'UserAccount'
 
+
 class has_avatar(RelationDefinition):
     subject = 'UserAccount'
     object = 'ExternalUri'
-
--- a/setup.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/setup.py	Tue Jan 17 11:55:41 2017 +0100
@@ -27,10 +27,10 @@
 import shutil
 try:
     from os.path import exists, join, walk, dirname
-except ImportError: #PY3
+except ImportError:  # PY3
     from os.path import exists, join, dirname
     from os import walk
-    
+
 try:
     if os.environ.get('NO_SETUPTOOLS'):
         raise ImportError()  # do as there is no setuptools
@@ -155,6 +155,7 @@
     """extend install_lib command to handle  package __init__.py and
     include_dirs variable if necessary
     """
+
     def run(self):
         """overridden from install_lib class"""
         install_lib.install_lib.run(self)
@@ -172,6 +173,7 @@
     # overwrite InstallData to use sys.prefix instead of the egg directory
     class MyInstallData(old_install_data):
         """A class that manages data files installation"""
+
         def run(self):
             _old_install_dir = self.install_dir
             if self.install_dir.endswith('egg'):
--- a/sobjects.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/sobjects.py	Tue Jan 17 11:55:41 2017 +0100
@@ -26,16 +26,19 @@
 except ImportError:
     DataFeedParser = None
 
+
 def get_subject(g, pred, obj):
     subjects = list(g.subjects(pred, obj))
     assert len(subjects) == 1
     return subjects[0]
 
+
 def get_object(g, subj, pred):
     objects = list(g.objects(subj, pred))
     assert len(objects) == 1
     return objects[0]
 
+
 def parse_blogpost_sioc(url):
     g = rdflib.ConjunctiveGraph()
     g.parse(url)
@@ -45,9 +48,9 @@
         item['content'] = unicode(get_object(g, post, SIOC.content))
         yield item
 
-format_map = {'application/xhtml+xml':u'text/html',
-              'text/html':u'text/html',
-              'text/plain':u'text/plain',
+format_map = {'application/xhtml+xml': u'text/html',
+              'text/html': u'text/html',
+              'text/plain': u'text/plain',
               }
 
 IMG_SPIES = ['http://feeds.feedburner.com',
@@ -57,6 +60,7 @@
              'http://stats.wordpress.com/',
              ]
 
+
 def is_img_spy(node):
     if node.tag != 'img':
         return False
@@ -65,12 +69,14 @@
             return True
     return False
 
+
 def is_tweetmeme_spy(node):
     href = node.get('href')
     if href and href.startswith('http://api.tweetmeme.com/share'):
         return True
     return False
 
+
 def remove_content_spies(content):
     root = fromstring(content)
     if is_img_spy(root):
@@ -85,6 +91,7 @@
             anchor.drop_tree()
     return unicode(tostring(root))
 
+
 def parse_blogpost_rss(url):
     data = feedparser.parse(url)
     feed = data.feed
@@ -102,7 +109,7 @@
             content = entry.summary_detail.value
             mimetype = entry.summary_detail.type
         else:
-            content = u''#XXX entry.description?
+            content = u''  # XXX entry.description?
             mimetype = u'text/plain'
         if mimetype == u'text/html':
             content = remove_content_spies(content)
@@ -123,6 +130,7 @@
         item['cwuri'] = feed.link
         yield item
 
+
 def parse_microblogpost_rss(url):
     feed = feedparser.parse(url)
     for entry in feed.entries:
@@ -143,7 +151,7 @@
         item['content_format'] = format_map.get(mimetype, u'text/plain')
         item['creation_date'] = datetime(*entry.date_parsed[:6])
         item['modification_date'] = datetime(*entry.date_parsed[:6])
-        item['author'] = feed.channel.link # true for twitter
+        item['author'] = feed.channel.link  # true for twitter
         item['cwuri'] = feed.channel.link
         for link in entry.links:
             if link.type.startswith('image/') and link.rel == 'image':
@@ -154,10 +162,12 @@
             item['avatar'] = get_twitter_avatar(screen_name)
         yield item
 
+
 def search_twitter(word):
     import urllib2
     from simplejson import loads
-    data = urllib2.urlopen('http://search.twitter.com/search.json?q=%s&rpp=100' % word).read()
+    data = urllib2.urlopen(
+        'http://search.twitter.com/search.json?q=%s&rpp=100' % word).read()
     results = loads(data)
     # process results
     # print results
@@ -165,11 +175,13 @@
 
 AVATAR_CACHE = {}
 
+
 def get_twitter_avatar(screen_name):
     if screen_name not in AVATAR_CACHE:
         from urllib2 import urlopen
         import simplejson
-        data = urlopen('http://api.twitter.com/1/users/show.json?screen_name=%s' % screen_name).read()
+        data = urlopen(
+            'http://api.twitter.com/1/users/show.json?screen_name=%s' % screen_name).read()
         user = simplejson.loads(data)
         AVATAR_CACHE[screen_name] = user['profile_image_url']
     return AVATAR_CACHE[screen_name]
@@ -180,17 +192,17 @@
         entity_type = 'BlogEntry'
 
         def process(self, url):
-            stats = {'update':0, 'creation':0}
+            stats = {'update': 0, 'creation': 0}
             for item in self.parse(url):
                 author = item.pop('author', None)
                 avatar = item.pop('avatar', None)
                 euri = self.sget_entity('ExternalUri', uri=item.pop('uri'))
                 if euri.same_as:
-                    #sys.stdout.write('.')
+                    # sys.stdout.write('.')
                     stats['update'] += 1
                     post = self.update_blogpost(euri.same_as[0], item)
                 else:
-                    #sys.stdout.write('+')
+                    # sys.stdout.write('+')
                     stats['creation'] += 1
                     post = self.create_blogpost(item, euri)
                 if author:
@@ -199,7 +211,7 @@
                     if avatar:
                         auri = self.sget_entity('ExternalUri', uri=avatar)
                         self.sget_relation(account.eid, 'has_avatar', auri.eid)
-                #sys.stdout.flush()
+                # sys.stdout.flush()
             return stats
 
         def create_blogpost(self, item, uri):
--- a/test/test_blog.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/test/test_blog.py	Tue Jan 17 11:55:41 2017 +0100
@@ -1,6 +1,7 @@
 from logilab.common.testlib import unittest_main
 from cubicweb.devtools.testlib import AutomaticWebTest
 
+
 class AutomaticWebTest(AutomaticWebTest):
 
     def to_test_etypes(self):
--- a/test/unittest_blog.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/test/unittest_blog.py	Tue Jan 17 11:55:41 2017 +0100
@@ -11,19 +11,23 @@
         with self.admin_access.client_cnx() as cnx:
             cubicweb_blog = cnx.create_entity('Blog', title=u'cubicweb',
                                               description=u"cubicweb c'est beau")
-            blog_entry_1 = cnx.create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
+            blog_entry_1 = cnx.create_entity(
+                'BlogEntry', title=u"hop", content=u"cubicweb hop")
             blog_entry_1.cw_set(entry_of=cubicweb_blog)
-            blog_entry_2 = cnx.create_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
+            blog_entry_2 = cnx.create_entity(
+                'BlogEntry', title=u"yes",  content=u"cubicweb yes")
             blog_entry_2.cw_set(entry_of=cubicweb_blog)
             self.assertEqual(len(MAILBOX), 0)
             cnx.commit()
             self.assertEqual(len(MAILBOX), 0)
-            blog_entry_1.cw_adapt_to('IWorkflowable').fire_transition('publish')
+            blog_entry_1.cw_adapt_to(
+                'IWorkflowable').fire_transition('publish')
             cnx.commit()
             self.assertEqual(len(MAILBOX), 1)
             mail = MAILBOX[0]
             self.assertEqual(mail.subject, '[data] hop')
-            blog_entry_2.cw_adapt_to('IWorkflowable').fire_transition('publish')
+            blog_entry_2.cw_adapt_to(
+                'IWorkflowable').fire_transition('publish')
             cnx.commit()
             self.assertEqual(len(MAILBOX), 2)
             mail = MAILBOX[1]
@@ -51,7 +55,6 @@
             self.assertEqual(xml.count("toto"), 0)
             self.assertEqual(xml.count("tutu"), content.count("tutu"))
 
-
     def test_prevnext(self):
         with self.admin_access.client_cnx() as cnx:
             e1 = cnx.create_entity('BlogEntry', title=u'a', content=u'a')
--- a/views/__init__.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/views/__init__.py	Tue Jan 17 11:55:41 2017 +0100
@@ -3,8 +3,10 @@
 from cubicweb.web.views import ibreadcrumbs
 from cubicweb.web.views.autoform import AutomaticEntityForm
 
+
 class BlogEntryIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
     __select__ = is_instance('BlogEntry', 'MicroBlogEntry')
+
     def parent_entity(self):
         return self.entity.entry_of and self.entity.entry_of[0] or None
 
@@ -34,7 +36,7 @@
             rset = self._cw.execute(rql % (order, operator),
                                     {'eid': self.entity.eid})
         if rset:
-            return rset.get_entity(0,0)
+            return rset.get_entity(0, 0)
 
 
 def registration_callback(vreg):
@@ -63,6 +65,7 @@
 
     if 'preview' in loaded_cubes:
         from cubes.preview.views.forms import PreviewFormMixin
+
         class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
             preview_mode = 'inline'
             __select__ = AutomaticEntityForm.__select__ & is_instance('Blog', 'BlogEntry',
--- a/views/blog.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/views/blog.py	Tue Jan 17 11:55:41 2017 +0100
@@ -48,7 +48,8 @@
 
 class SubscribeToBlogComponent(component.EntityCtxComponent):
     __regid__ = 'blogsubscribe'
-    __select__ = component.EntityVComponent.__select__ & is_instance('Blog', 'MicroBlog')
+    __select__ = component.EntityVComponent.__select__ & is_instance(
+        'Blog', 'MicroBlog')
     context = 'ctxtoolbar'
 
     def render_body(self, w):
@@ -57,4 +58,3 @@
             xml_escape(entity.cw_adapt_to('IFeed').rss_feed_url()),
             self._cw.uiprops['RSS_LOGO_16'],
             self._cw._(u'subscribe to this blog')))
-
--- a/views/boxes.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/views/boxes.py	Tue Jan 17 11:55:41 2017 +0100
@@ -30,7 +30,7 @@
     context = 'left'
 
     def render_body(self, w):
-        #FIXME doesn't handle (yet) multiple blogs
+        # FIXME doesn't handle (yet) multiple blogs
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         rset = entity.related('entry_of', 'object')
         self._cw.view('cw.archive.by_date', rset, maxentries=6,
@@ -50,6 +50,7 @@
                                                     rset=entity.related('entry_of', 'subject'))
         box.render_body(w)
 
+
 class BlogByAuthorBox(component.CtxComponent):
     __regid__ = 'blog.archives_by_author'
     __select__ = (component.CtxComponent.__select__
@@ -60,7 +61,7 @@
     context = 'left'
 
     def render_body(self, w):
-        #FIXME doesn't handle (yet) multiple blogs
+        # FIXME doesn't handle (yet) multiple blogs
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         rset = entity.related('entry_of', 'object')
         self._cw.view('cw.archive.by_author', rset,
@@ -80,6 +81,7 @@
                                                     rset=entity.related('entry_of', 'subject'))
         box.render_body(w)
 
+
 class LatestBlogsBox(component.CtxComponent):
     """display a box with latest blogs and rss"""
     __regid__ = 'blog.latest_blogs'
@@ -140,6 +142,7 @@
             'X title T, X creation_date CD, X entry_of B, B eid %(b)s',
             {'b': blog.eid})
 
+
 class LatestBlogsBlogEntryBox(LatestBlogsBox):
     """display a box with latest blogs and rss, filtered for a particular blog
     """
@@ -151,10 +154,9 @@
 
     def latest_blogs_rset(self):
         blogentry = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
-        #FIXME doesn't handle (yet) multiple blogs
-        blog = blogentry.related('entry_of', 'subject').get_entity(0,0)
+        # FIXME doesn't handle (yet) multiple blogs
+        blog = blogentry.related('entry_of', 'subject').get_entity(0, 0)
         return self._cw.execute(
             'Any X,T,CD ORDERBY CD DESC LIMIT 5 WHERE '
             'X title T, X creation_date CD, X entry_of B, B eid %(b)s',
             {'b': blog.eid})
-
--- a/views/entry.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/views/entry.py	Tue Jan 17 11:55:41 2017 +0100
@@ -34,7 +34,8 @@
 _afs = uicfg.autoform_section
 _afs.tag_subject_of(('BlogEntry', 'entry_of', 'Blog'), 'main', 'attributes')
 
-# blog entries #################################################################
+# blog entries ###########################################################
+
 
 def render_blogentry_title(req, w, entity):
     w(u'<h1>%s</h1>' % entity.view('incontext'))
@@ -82,13 +83,16 @@
 
 # don't show workflow history for blog entry
 class BlogEntryWFHistoryVComponent(workflow.WFHistoryVComponent):
-    __select__ = workflow.WFHistoryVComponent.__select__ & is_instance('BlogEntry')
+    __select__ = workflow.WFHistoryVComponent.__select__ & is_instance(
+        'BlogEntry')
 
     def render(self, w, **kwargs):
         pass
 
+
 class BlogEntrySameETypeListView(baseviews.SameETypeListView):
-    __select__ = baseviews.SameETypeListView.__select__ & is_instance('BlogEntry')
+    __select__ = baseviews.SameETypeListView.__select__ & is_instance(
+        'BlogEntry')
     countrql = ('Any COUNT(B) WHERE B is BlogEntry, '
                 'B creation_date >= %(firstday)s, B creation_date <= %(lastday)s')
     item_vid = 'blog'
@@ -98,7 +102,8 @@
         super(BlogEntrySameETypeListView, self).call(**kwargs)
         # XXX Iirk, IPrevNext
         if 'year' in self._cw.form and 'month' in self._cw.form:
-            self.render_next_previous(int(self._cw.form['year']), int(self._cw.form['month']))
+            self.render_next_previous(
+                int(self._cw.form['year']), int(self._cw.form['month']))
 
     def render_next_previous(self, year, month):
         if month == 12:
@@ -110,12 +115,12 @@
             previousmonth = 12
             year = year - 1
         else:
-            previousmonth = month -1
+            previousmonth = month - 1
         self.w(u'<div class="prevnext">')
-        self.w(u'<span class="previousmonth">%s</span>' \
+        self.w(u'<span class="previousmonth">%s</span>'
                % self.render_link(year, previousmonth,
                                   xml_escape(u'<< ' + self._cw._(u'previous month'))))
-        self.w(u'<span class="nextmonth">%s</span>' \
+        self.w(u'<span class="nextmonth">%s</span>'
                % self.render_link(year, nextmonth,
                                   xml_escape(self._cw._(u'next month') + u' >>')))
         self.w(u'</div>')
@@ -130,14 +135,16 @@
         rql = ('Any B, BD ORDERBY BD DESC '
                'WHERE B is BlogEntry, B creation_date BD, '
                'B creation_date >= "%s", B creation_date <= "%s"' %
-                (firstday.strftime('%Y-%m-%d'), lastday.strftime('%Y-%m-%d')))
-        label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[month-1]), year,
+               (firstday.strftime('%Y-%m-%d'), lastday.strftime('%Y-%m-%d')))
+        label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[month - 1]), year,
                                  nmb_entries)
-        vtitle = '%s %s' % (display_name(self._cw, 'BlogEntry', 'plural'), label)
+        vtitle = '%s %s' % (display_name(
+            self._cw, 'BlogEntry', 'plural'), label)
         url = self._cw.build_url('view', rql=rql, vtitle=vtitle,
                                  month=month, year=year)
         return u'<a href="%s">%s</a>' % (xml_escape(url), atitle)
 
+
 class BlogEntryBlogView(EntityView):
     __regid__ = 'blog'
     __select__ = is_instance('BlogEntry')
@@ -172,7 +179,7 @@
         w = reldata.append
         schema = self._cw.vreg.schema
         if 'comments' in schema and \
-               'BlogEntry' in schema.rschema('comments').objects():
+                'BlogEntry' in schema.rschema('comments').objects():
             from cubes.comment.entities import subcomments_count
             count = subcomments_count(entity)
             if count:
@@ -199,10 +206,10 @@
     __select__ = paginated_rset() & sorted_rset() & is_instance('BlogEntry')
 
     def index_display(self, start, stop):
-        return unicode(int(start / self.page_size)+1)
+        return unicode(int(start / self.page_size) + 1)
 
 
-# micro blog entries ###########################################################
+# micro blog entries #####################################################
 
 def format_microblog(entity):
     if entity.has_creator:
@@ -232,6 +239,7 @@
             u'<span class="meta"><a href="%s">%s</a></span>'
             u'</div>' % (ablock, content, entity.absolute_url(), entity.creation_date))
 
+
 class MicroBlogEntryPrimaryView(primary.PrimaryView):
     __select__ = primary.PrimaryView.__select__ & is_instance('MicroBlogEntry')
 
@@ -240,8 +248,10 @@
         entity = self.cw_rset.get_entity(row, col)
         self.w(format_microblog(entity))
 
+
 class MicroBlogEntrySameETypeListView(baseviews.SameETypeListView):
-    __select__ = baseviews.SameETypeListView.__select__ & is_instance('MicroBlogEntry')
+    __select__ = baseviews.SameETypeListView.__select__ & is_instance(
+        'MicroBlogEntry')
 
     def cell_call(self, row, col):
         self._cw.add_css('cubes.blog.css')
@@ -250,6 +260,7 @@
 
 _CLEAN_STYLE_RE = re.compile(r'<style .*?</style>', re.MULTILINE | re.DOTALL)
 
+
 class BlogEntryRSSItemView(RSSItemView):
     __select__ = is_instance('BlogEntry')
 
--- a/views/urlpublishing.py	Tue Jan 17 11:54:19 2017 +0100
+++ b/views/urlpublishing.py	Tue Jan 17 11:55:41 2017 +0100
@@ -3,6 +3,7 @@
 
 from cubicweb.web.views.urlrewrite import SimpleReqRewriter, rgx
 
+
 class BlogReqRewriter(SimpleReqRewriter):
     rules = [
         # links generated by archives by date/author boxes
@@ -11,7 +12,8 @@
               )),
         (rgx('/(micro)?blog/([0-9]+)/blogentries/([a-z_]+)'),
          dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s, '
-              'B created_by U, U login "%(user)s"' % {'eid': r'\2', 'user': r'\3'},
+              'B created_by U, U login "%(user)s"' % {
+                  'eid': r'\2', 'user': r'\3'},
               user=r'\2')),
         (rgx('/(micro)?blog/([0-9]+)/blogentries/([0-9]{4})'),
          dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s'
@@ -19,13 +21,14 @@
               )),
         (rgx('/(micro)?blog/([0-9]+)/blogentries/([0-9]{4})/([0-9]{2})'),
          dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s '
-              'HAVING YEAR(BD)= %(year)s, MONTH(BD)=%(month)s' % {'eid': r'\2', 'year': r'\3', 'month': r'\4'},
+              'HAVING YEAR(BD)= %(year)s, MONTH(BD)=%(month)s' % {
+                  'eid': r'\2', 'year': r'\3', 'month': r'\4'},
               )),
 
         # XXX use or kill
         (rgx('/blogentry/([a-z_]+)'),
          dict(rql='Any B,BD ORDERBY BD DESC WHERE B is BlogEntry, B creation_date BD, B created_by U, U login "%(user)s"' % {'user': r'\1'},
-              user = r'\1')),
+              user=r'\1')),
         (rgx('/blogentry/([a-z_]+)\.rss'),
          dict(rql='Any B,BD ORDERBY BD DESC LIMIT 20 WHERE B is BlogEntry, B creation_date BD, B created_by U, U login "%(user)s"' % {'user': r'\1'}, vid='rss')),
 
@@ -38,4 +41,4 @@
                   'HAVING YEAR(BD) = %(year)s, MONTH(BD) = %(month)s' % {'year': r'\1',
                                                                          'month': r'\2'})),
 
-        ]
+    ]