Flake8 bits with some copyright updates
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 24 Nov 2016 16:58:50 +0100
changeset 11870 3a84a79c4ed5
parent 11869 d8b66e3fd335
child 11871 5f71460236a4
Flake8 bits with some copyright updates
cubicweb/cwconfig.py
cubicweb/cwctl.py
cubicweb/etwist/request.py
cubicweb/etwist/server.py
cubicweb/etwist/service.py
cubicweb/rset.py
cubicweb/rtags.py
cubicweb/test/unittest_req.py
cubicweb/test/unittest_rset.py
cubicweb/web/formfields.py
cubicweb/web/test/unittest_views_forms.py
cubicweb/web/views/basetemplates.py
cubicweb/web/views/editcontroller.py
cubicweb/web/views/forms.py
cubicweb/web/views/staticcontrollers.py
flake8-ok-files.txt
--- a/cubicweb/cwconfig.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/cwconfig.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -177,10 +177,9 @@
 
    Directory where pid files will be written
 """
+
 from __future__ import print_function
 
-
-
 import importlib
 import logging
 import logging.config
@@ -194,7 +193,7 @@
 import stat
 import sys
 from threading import Lock
-from warnings import warn, filterwarnings
+from warnings import filterwarnings
 
 from six import text_type
 
@@ -220,6 +219,7 @@
     except IndexError:
         raise ConfigurationError('no such config %r (check it exists with "cubicweb-ctl list")' % name)
 
+
 def possible_configurations(directory):
     """return a list of installed configurations in a directory
     according to \*-ctl files
@@ -227,6 +227,7 @@
     return [name for name in ('repository', 'all-in-one')
             if exists(join(directory, '%s.conf' % name))]
 
+
 def guess_configuration(directory):
     """try to guess the configuration to use for a directory. If multiple
     configurations are found, ConfigurationError is raised
@@ -237,6 +238,7 @@
                                  % (directory, modes))
     return modes[0]
 
+
 def _find_prefix(start_path=None):
     """Return the prefix path of CubicWeb installation.
 
--- a/cubicweb/cwctl.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/cwctl.py	Thu Nov 24 16:58:50 2016 +0100
@@ -20,15 +20,13 @@
 """
 from __future__ import print_function
 
-
-
 # *ctl module should limit the number of import to be imported as quickly as
 # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash
 # completion). So import locally in command helpers.
 import sys
 from warnings import warn, filterwarnings
 from os import remove, listdir, system, pathsep
-from os.path import exists, join, isfile, isdir, dirname, abspath
+from os.path import exists, join, isdir, dirname, abspath
 
 try:
     from os import kill, getpgid
@@ -43,7 +41,6 @@
 from logilab.common.clcommands import CommandLine
 from logilab.common.shellutils import ASK
 from logilab.common.configuration import merge_options
-from logilab.common.deprecation import deprecated
 
 from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage
 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CWDEV, CONFIGURATIONS
@@ -54,6 +51,7 @@
 CWCTL = CommandLine('cubicweb-ctl', 'The CubicWeb swiss-knife.',
                     version=version, check_duplicated_command=False)
 
+
 def wait_process_end(pid, maxtry=10, waittime=1):
     """wait for a process to actually die"""
     import signal
@@ -62,19 +60,21 @@
     while nbtry < maxtry:
         try:
             kill(pid, signal.SIGUSR1)
-        except (OSError, AttributeError): # XXX win32
+        except (OSError, AttributeError):  # XXX win32
             break
         nbtry += 1
         sleep(waittime)
     else:
         raise ExecutionError('can\'t kill process %s' % pid)
 
+
 def list_instances(regdir):
     if isdir(regdir):
         return sorted(idir for idir in listdir(regdir) if isdir(join(regdir, idir)))
     else:
         return []
 
+
 def detect_available_modes(templdir):
     modes = []
     for fname in ('schema', 'schema.py'):
--- a/cubicweb/etwist/request.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/etwist/request.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -38,7 +38,7 @@
             # 3.16.4 backward compat
             if len(self.form[key]) == 1:
                 self.form[key] = self.form[key][0]
-        self.content = self._twreq.content # stream
+        self.content = self._twreq.content  # stream
 
     def http_method(self):
         """returns 'POST', 'GET', 'HEAD', etc."""
@@ -52,7 +52,7 @@
         :param includeparams:
            boolean indicating if GET form parameters should be kept in the path
         """
-        path = self._twreq.uri[1:] # remove the root '/'
+        path = self._twreq.uri[1:]  # remove the root '/'
         if not includeparams:
             path = path.split('?', 1)[0]
         return path
--- a/cubicweb/etwist/server.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/etwist/server.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -17,15 +17,11 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """twisted server for CubicWeb web instances"""
 
-
 import sys
-import select
 import traceback
 import threading
 from cgi import FieldStorage, parse_header
 
-from six.moves.urllib.parse import urlsplit, urlunsplit
-
 from cubicweb.statsd_logger import statsd_timeit
 
 from twisted.internet import reactor, task, threads
@@ -44,6 +40,7 @@
 from cubicweb.etwist.request import CubicWebTwistedRequestAdapter
 from cubicweb.etwist.http import HTTPResponse
 
+
 def start_task(interval, func):
     lc = task.LoopingCall(func)
     # wait until interval has expired to actually start the task, else we have
--- a/cubicweb/etwist/service.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/etwist/service.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -38,15 +38,17 @@
 from cubicweb import set_log_methods
 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
 
+
 def _check_env(env):
     env_vars = ('CW_INSTANCES_DIR', 'CW_INSTANCES_DATA_DIR', 'CW_RUNTIME_DIR')
     for var in env_vars:
         if var not in env:
-            raise Exception('The environment variables %s must be set.' % \
+            raise Exception('The environment variables %s must be set.' %
                             ', '.join(env_vars))
     if not env.get('USERNAME'):
         env['USERNAME'] = 'cubicweb'
 
+
 class CWService(object, win32serviceutil.ServiceFramework):
     _svc_name_ = None
     _svc_display_name_ = None
--- a/cubicweb/rset.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/rset.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -94,10 +94,10 @@
 
         if not self.description:
             return pattern % (self.rql, len(self.rows),
-                                                     '\n'.join(str(r) for r in rows))
+                              '\n'.join(str(r) for r in rows))
         return pattern % (self.rql, len(self.rows),
-                                                 '\n'.join('%s (%s)' % (r, d)
-                                                           for r, d in zip(rows, self.description)))
+                          '\n'.join('%s (%s)' % (r, d)
+                                    for r, d in zip(rows, self.description)))
 
     def possible_actions(self, **kwargs):
         if self._rsetactions is None:
@@ -120,7 +120,7 @@
 
     def __getitem__(self, i):
         """returns the ith element of the result set"""
-        return self.rows[i] #ResultSetRow(self.rows[i])
+        return self.rows[i]
 
     def __iter__(self):
         """Returns an iterator over rows"""
@@ -132,7 +132,7 @@
         # at least rql could be fixed now that we have union and sub-queries
         # but I tend to think that since we have that, we should not need this
         # method anymore (syt)
-        rset = ResultSet(self.rows+rset.rows, self.rql, self.args,
+        rset = ResultSet(self.rows + rset.rows, self.rql, self.args,
                          self.description + rset.description)
         rset.req = self.req
         return rset
@@ -163,7 +163,7 @@
         rset = self.copy(rows, descr)
         for row, desc in zip(self.rows, self.description):
             nrow, ndesc = transformcb(row, desc)
-            if ndesc: # transformcb returns None for ndesc to skip that row
+            if ndesc:  # transformcb returns None for ndesc to skip that row
                 rows.append(nrow)
                 descr.append(ndesc)
         rset.rowcount = len(rows)
@@ -192,7 +192,6 @@
         rset.rowcount = len(rows)
         return rset
 
-
     def sorted_rset(self, keyfunc, reverse=False, col=0):
         """sorts the result set according to a given keyfunc
 
@@ -308,7 +307,7 @@
             newselect = stmts.Select()
             newselect.limit = limit
             newselect.offset = offset
-            aliases = [nodes.VariableRef(newselect.get_variable(chr(65+i), i))
+            aliases = [nodes.VariableRef(newselect.get_variable(chr(65 + i), i))
                        for i in range(len(rqlst.children[0].selection))]
             for vref in aliases:
                 newselect.append_selected(nodes.VariableRef(vref.variable))
@@ -336,7 +335,7 @@
 
         :rtype: `ResultSet`
         """
-        stop = limit+offset
+        stop = limit + offset
         rows = self.rows[offset:stop]
         descr = self.description[offset:stop]
         if inplace:
@@ -592,7 +591,7 @@
             if row != last:
                 if last is not None:
                     result[-1][1] = i - 1
-                result.append( [i, None, row] )
+                result.append([i, None, row])
                 last = row
         if last is not None:
             result[-1][1] = i
@@ -665,7 +664,7 @@
                 try:
                     entity = self.get_entity(row, index)
                     return entity, rel.r_type
-                except NotAnEntity as exc:
+                except NotAnEntity:
                     return None, None
         return None, None
 
@@ -683,12 +682,14 @@
                 return rhs.eval(self.args)
         return None
 
+
 def _get_variable(term):
     # XXX rewritten const
     # use iget_nodes for (hack) case where we have things like MAX(V)
     for vref in term.iget_nodes(nodes.VariableRef):
         return vref.variable
 
+
 def attr_desc_iterator(select, selectidx, rootidx):
     """return an iterator on a list of 2-uple (index, attr_relation)
     localizing attribute relations of the main variable in a result's row
--- a/cubicweb/rtags.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/rtags.py	Thu Nov 24 16:58:50 2016 +0100
@@ -38,16 +38,17 @@
 
 
 import logging
-from warnings import warn
 
 from six import string_types
 
 from logilab.common.logging_ext import set_log_methods
 from logilab.common.registry import RegistrableInstance, yes
 
+
 def _ensure_str_key(key):
     return tuple(str(k) for k in key)
 
+
 class RegistrableRtags(RegistrableInstance):
     __registry__ = 'uicfg'
     __select__ = yes()
--- a/cubicweb/test/unittest_req.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/test/unittest_req.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -19,23 +19,23 @@
 from logilab.common.testlib import TestCase, unittest_main
 from cubicweb import ObjectNotFound
 from cubicweb.req import RequestSessionBase, FindEntityError
-from cubicweb.devtools import ApptestConfiguration
 from cubicweb.devtools.testlib import CubicWebTC
 from cubicweb import Unauthorized
 
+
 class RequestTC(TestCase):
     def test_rebuild_url(self):
         rebuild_url = RequestSessionBase(None).rebuild_url
         self.assertEqual(rebuild_url('http://logilab.fr?__message=pouet', __message='hop'),
-                          'http://logilab.fr?__message=hop')
+                         'http://logilab.fr?__message=hop')
         self.assertEqual(rebuild_url('http://logilab.fr', __message='hop'),
-                          'http://logilab.fr?__message=hop')
+                         'http://logilab.fr?__message=hop')
         self.assertEqual(rebuild_url('http://logilab.fr?vid=index', __message='hop'),
-                          'http://logilab.fr?__message=hop&vid=index')
+                         'http://logilab.fr?__message=hop&vid=index')
 
     def test_build_url(self):
         req = RequestSessionBase(None)
-        req.from_controller = lambda : 'view'
+        req.from_controller = lambda: 'view'
         req.relative_path = lambda includeparams=True: None
         req.base_url = lambda secure=None: 'http://testing.fr/cubicweb/'
         self.assertEqual(req.build_url(), u'http://testing.fr/cubicweb/view')
@@ -49,8 +49,10 @@
         req = RequestSessionBase(None)
         self.assertEqual(req.ensure_ro_rql('Any X WHERE X is CWUser'), None)
         self.assertEqual(req.ensure_ro_rql('  Any X WHERE X is CWUser  '), None)
-        self.assertRaises(Unauthorized, req.ensure_ro_rql, 'SET X login "toto" WHERE X is CWUser')
-        self.assertRaises(Unauthorized, req.ensure_ro_rql, '   SET X login "toto" WHERE X is CWUser   ')
+        self.assertRaises(Unauthorized, req.ensure_ro_rql,
+                          'SET X login "toto" WHERE X is CWUser')
+        self.assertRaises(Unauthorized, req.ensure_ro_rql,
+                          '   SET X login "toto" WHERE X is CWUser   ')
 
 
 class RequestCWTC(CubicWebTC):
--- a/cubicweb/test/unittest_rset.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/test/unittest_rset.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,5 +1,5 @@
 # coding: utf-8
-# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -44,12 +44,12 @@
     def test_relations_description(self):
         """tests relations_description() function"""
         queries = {
-            'Any U,L,M where U is CWUser, U login L, U mail M' : [(1, 'login', 'subject'), (2, 'mail', 'subject')],
-            'Any U,L,M where U is CWUser, L is Foo, U mail M' : [(2, 'mail', 'subject')],
-            'Any C,P where C is Company, C employs P' : [(1, 'employs', 'subject')],
-            'Any C,P where C is Company, P employed_by P' : [],
-            'Any C where C is Company, C employs P' : [],
-            }
+            'Any U,L,M where U is CWUser, U login L, U mail M': [(1, 'login', 'subject'), (2, 'mail', 'subject')],
+            'Any U,L,M where U is CWUser, L is Foo, U mail M': [(2, 'mail', 'subject')],
+            'Any C,P where C is Company, C employs P': [(1, 'employs', 'subject')],
+            'Any C,P where C is Company, P employed_by P': [],
+            'Any C where C is Company, C employs P': [],
+        }
         for rql, relations in queries.items():
             result = list(attr_desc_iterator(parse(rql).children[0], 0, 0))
             self.assertEqual((rql, result), (rql, relations))
@@ -57,9 +57,10 @@
     def test_relations_description_indexed(self):
         """tests relations_description() function"""
         queries = {
-            'Any C,U,P,L,M where C is Company, C employs P, U is CWUser, U login L, U mail M' :
-            {0: [(2,'employs', 'subject')], 1: [(3,'login', 'subject'), (4,'mail', 'subject')]},
-            }
+            'Any C,U,P,L,M where C is Company, C employs P, U is CWUser, U login L, U mail M':
+            {0: [(2, 'employs', 'subject')],
+             1: [(3, 'login', 'subject'), (4, 'mail', 'subject')]},
+        }
         for rql, results in queries.items():
             for idx, relations in results.items():
                 result = list(attr_desc_iterator(parse(rql).children[0], idx, idx))
@@ -284,7 +285,7 @@
     def test_get_entity_simple(self):
         with self.admin_access.web_request() as req:
             req.create_entity('CWUser', login=u'adim', upassword='adim',
-                                         surname=u'di mascio', firstname=u'adrien')
+                              surname=u'di mascio', firstname=u'adrien')
             req.drop_entity_cache()
             e = req.execute('Any X,T WHERE X login "adim", X surname T').get_entity(0, 0)
             self.assertEqual(e.cw_attr_cache['surname'], 'di mascio')
--- a/cubicweb/web/formfields.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/formfields.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -111,6 +111,7 @@
     result += sorted(partresult)
     return result
 
+
 _MARKER = nullobject()
 
 
@@ -361,7 +362,6 @@
             if callable(self.value):
                 return self.value(form, self)
             return self.value
-        formattr = '%s_%s_default' % (self.role, self.name)
         if self.eidparam and self.role is not None:
             if form._cw.vreg.schema.rschema(self.name).final:
                 return form.edited_entity.e_schema.default(self.name)
--- a/cubicweb/web/test/unittest_views_forms.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/test/unittest_views_forms.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2014-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
--- a/cubicweb/web/views/basetemplates.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/views/basetemplates.py	Thu Nov 24 16:58:50 2016 +0100
@@ -18,20 +18,20 @@
 """default templates for CubicWeb web client"""
 
 
-from cubicweb import _
-
 from logilab.mtconverter import xml_escape
 from logilab.common.deprecation import class_renamed
 from logilab.common.registry import objectify_predicate
 from logilab.common.decorators import classproperty
 
-from cubicweb.predicates import match_kwargs, no_cnx, anonymous_user
+from cubicweb import _
+from cubicweb.predicates import match_kwargs, anonymous_user
 from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW, StartupView
 from cubicweb.utils import UStringIO
 from cubicweb.schema import display_name
-from cubicweb.web import component, formfields as ff, formwidgets as fw
+from cubicweb.web import formfields as ff, formwidgets as fw
 from cubicweb.web.views import forms
 
+
 # main templates ##############################################################
 
 class LogInOutTemplate(MainTemplate):
@@ -92,6 +92,7 @@
     if req.form.get('__modal', None):
         return 1
 
+
 @objectify_predicate
 def templatable_view(cls, req, rset, *args, **kwargs):
     view = kwargs.pop('view', None)
@@ -176,7 +177,6 @@
 
     def template_html_header(self, content_type, page_title, additional_headers=()):
         w = self.whead
-        lang = self._cw.lang
         self.write_doctype()
         self._cw.html_headers.define_var('BASE_URL', self._cw.base_url())
         self._cw.html_headers.define_var('DATA_URL', self._cw.datadir_url)
@@ -215,7 +215,6 @@
         boxes = list(self._cw.vreg['ctxcomponents'].poss_visible_objects(
             self._cw, rset=self.cw_rset, view=view, context=context))
         if boxes:
-            getlayout = self._cw.vreg['components'].select
             self.w(u'<td id="navColumn%s"><div class="navboxes">\n' % context.capitalize())
             for box in boxes:
                 box.render(w=self.w, view=view)
@@ -248,7 +247,6 @@
 
     def template_header(self, content_type, view=None, page_title='', additional_headers=()):
         w = self.whead
-        lang = self._cw.lang
         self.write_doctype()
         w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
           % (content_type, self._cw.encoding))
@@ -269,7 +267,6 @@
         page_title = page_title or view.page_title()
         additional_headers = additional_headers or view.html_headers()
         whead = self.whead
-        lang = self._cw.lang
         self.write_doctype()
         whead(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
               % (content_type, self._cw.encoding))
@@ -337,10 +334,10 @@
 
     def alternates(self):
         urlgetter = self._cw.vreg['components'].select_or_none('rss_feed_url',
-                                                           self._cw, rset=self.cw_rset)
+                                                               self._cw, rset=self.cw_rset)
         if urlgetter is not None:
             self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n'
-                       %  xml_escape(urlgetter.feed_url()))
+                       % xml_escape(urlgetter.feed_url()))
 
 
 class HTMLPageHeader(View):
@@ -406,6 +403,7 @@
             if i < (len(footeractions) - 1):
                 self.w(u' | ')
 
+
 class HTMLContentHeader(View):
     """default html page content header:
     * include message component if selectable for this request
@@ -439,6 +437,7 @@
                 comp.render(w=self.w, view=view)
             self.w(u'</div>')
 
+
 class BaseLogForm(forms.FieldsForm):
     """Abstract Base login form to be used by any login form
     """
@@ -461,7 +460,7 @@
                         fw.ResetButton(label=_('cancel'),
                                        attrs={'class': 'loginButton',
                                               'onclick': onclick}),]
-        ## Can't shortcut next access because __dict__ is a "dictproxy" which 
+        ## Can't shortcut next access because __dict__ is a "dictproxy" which
         ## does not support items assignement.
         # cls.__dict__['form_buttons'] = form_buttons
         return form_buttons
@@ -477,6 +476,7 @@
             return self._cw.build_url('login', __secure__=True, **url_args)
         return super(BaseLogForm, self).form_action()
 
+
 class LogForm(BaseLogForm):
     """Simple login form that send username and password
     """
@@ -488,7 +488,7 @@
     __password = ff.StringField('__password', label=_('password'),
                                 widget=fw.PasswordSingleInput({'class': 'data'}))
 
-    onclick_args =  ('popupLoginBox', '__login')
+    onclick_args = ('popupLoginBox', '__login')
 
 
 class LogFormView(View):
@@ -531,4 +531,5 @@
         form.render(w=self.w, table_class='', display_progress_div=False)
         cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
 
+
 LogFormTemplate = class_renamed('LogFormTemplate', LogFormView)
--- a/cubicweb/web/views/editcontroller.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/views/editcontroller.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -17,8 +17,6 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """The edit controller, automatically handling entity form submitting"""
 
-
-
 from warnings import warn
 from collections import defaultdict
 
@@ -26,16 +24,14 @@
 
 from six import text_type
 
-from logilab.common.deprecation import deprecated
 from logilab.common.graph import ordered_nodes
 
 from rql.utils import rqlvar_maker
 
-from cubicweb import _, Binary, ValidationError, UnknownEid
+from cubicweb import _, ValidationError, UnknownEid
 from cubicweb.view import EntityAdapter
 from cubicweb.predicates import is_instance
-from cubicweb.web import (INTERNAL_FIELD_VALUE, RequestError, NothingToEdit,
-                          ProcessFormError)
+from cubicweb.web import RequestError, NothingToEdit, ProcessFormError
 from cubicweb.web.views import basecontrollers, autoform
 
 
@@ -74,6 +70,7 @@
     except (ValueError, TypeError):
         return eid
 
+
 class RqlQuery(object):
     def __init__(self):
         self.edited = []
@@ -198,7 +195,7 @@
         req.data['pending_composite_delete'] = set()
         try:
             for formparams in self._ordered_formparams():
-                eid = self.edit_entity(formparams)
+                self.edit_entity(formparams)
         except (RequestError, NothingToEdit) as ex:
             if '__linkto' in req.form and 'eid' in req.form:
                 self.execute_linkto()
@@ -236,7 +233,7 @@
             neweid = entity.eid
         except ValidationError as ex:
             self._to_create[eid] = ex.entity
-            if self._cw.ajax_request: # XXX (syt) why?
+            if self._cw.ajax_request:  # XXX (syt) why?
                 ex.entity = eid
             raise
         self._to_create[eid] = neweid
@@ -268,7 +265,7 @@
         form = req.vreg['forms'].select(formid, req, entity=entity)
         eid = form.actual_eid(entity.eid)
         editedfields = formparams['_cw_entity_fields']
-        form.formvalues = {} # init fields value cache
+        form.formvalues = {}  # init fields value cache
         for field in form.iter_modified_fields(editedfields, entity):
             self.handle_formfield(form, field, rqlquery)
         # if there are some inlined field which were waiting for this entity's
@@ -279,9 +276,9 @@
             if self.errors:
                 errors = dict((f.role_name(), text_type(ex)) for f, ex in self.errors)
                 raise ValidationError(valerror_eid(entity.eid), errors)
-            if eid is None: # creation or copy
+            if eid is None:  # creation or copy
                 entity.eid = eid = self._insert_entity(etype, formparams['eid'], rqlquery)
-            elif rqlquery.edited: # edition of an existant entity
+            elif rqlquery.edited:  # edition of an existant entity
                 self.check_concurrent_edition(formparams, eid)
                 self._update_entity(eid, rqlquery)
         else:
@@ -294,7 +291,7 @@
             autoform.delete_relations(req, todelete)
         if '__cloned_eid' in formparams:
             entity.copy_relations(int(formparams['__cloned_eid']))
-        if is_main_entity: # only execute linkto for the main entity
+        if is_main_entity:  # only execute linkto for the main entity
             self.execute_linkto(entity.eid)
         return eid
 
@@ -303,10 +300,9 @@
         eschema = entity.e_schema
         try:
             for field, value in field.process_posted(form):
-                if not (
-                    (field.role == 'subject' and field.name in eschema.subjrels)
-                    or
-                    (field.role == 'object' and field.name in eschema.objrels)):
+                if not ((field.role == 'subject' and field.name in eschema.subjrels)
+                        or
+                        (field.role == 'object' and field.name in eschema.objrels)):
                     continue
 
                 rschema = self._cw.vreg.schema.rschema(field.name)
@@ -315,11 +311,11 @@
                     continue
 
                 if entity.has_eid():
-                    origvalues = set(data[0] for data in entity.related(field.name, field.role).rows)
+                    origvalues = set(row[0] for row in entity.related(field.name, field.role).rows)
                 else:
                     origvalues = set()
                 if value is None or value == origvalues:
-                    continue # not edited / not modified / to do later
+                    continue  # not edited / not modified / to do later
 
                 unlinked_eids = origvalues - value
 
@@ -333,7 +329,7 @@
                 elif form.edited_entity.has_eid():
                     self.handle_relation(form, field, value, origvalues)
                 else:
-                    form._cw.data['pending_others'].add( (form, field) )
+                    form._cw.data['pending_others'].add((form, field))
 
         except ProcessFormError as exc:
             self.errors.append((field, exc))
@@ -387,15 +383,10 @@
     def handle_relation(self, form, field, values, origvalues):
         """handle edition for the (rschema, x) relation of the given entity
         """
-        etype = form.edited_entity.e_schema
         rschema = self._cw.vreg.schema.rschema(field.name)
         if field.role == 'subject':
-            desttype = rschema.objects(etype)[0]
-            card = rschema.rdef(etype, desttype).cardinality[0]
             subjvar, objvar = 'X', 'Y'
         else:
-            desttype = rschema.subjects(etype)[0]
-            card = rschema.rdef(desttype, etype).cardinality[1]
             subjvar, objvar = 'Y', 'X'
         eid = form.edited_entity.eid
         if field.role == 'object' or not rschema.inlined or not values:
@@ -419,7 +410,7 @@
         for eid, etype in eidtypes:
             entity = self._cw.entity_from_eid(eid, etype)
             path, params = entity.cw_adapt_to('IEditControl').after_deletion_path()
-            redirect_info.add( (path, tuple(params.items())) )
+            redirect_info.add((path, tuple(params.items())))
             entity.cw_delete()
         if len(redirect_info) > 1:
             # In the face of ambiguity, refuse the temptation to guess.
@@ -431,7 +422,6 @@
         else:
             self._cw.set_message(self._cw._('entity deleted'))
 
-
     def check_concurrent_edition(self, formparams, eid):
         req = self._cw
         try:
@@ -446,7 +436,7 @@
             msg = _("Entity %(eid)s has changed since you started to edit it."
                     " Reload the page and reapply your changes.")
             # ... this is why we pass the formats' dict as a third argument.
-            raise ValidationError(eid, {None: msg}, {'eid' : eid})
+            raise ValidationError(eid, {None: msg}, {'eid': eid})
 
     def _action_apply(self):
         self._default_publish()
--- a/cubicweb/web/views/forms.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/views/forms.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -42,9 +42,6 @@
 but you'll use this one rarely.
 """
 
-
-
-
 import time
 import inspect
 
@@ -177,8 +174,10 @@
             return self._onsubmit
         except AttributeError:
             return "return freezeFormButtons('%(domid)s');" % dictattr(self)
+
     def _set_onsubmit(self, value):
         self._onsubmit = value
+
     onsubmit = property(_get_onsubmit, _set_onsubmit)
 
     def add_media(self):
@@ -210,6 +209,7 @@
             rset=self.cw_rset, row=self.cw_row, col=self.cw_col or 0)
 
     formvalues = None
+
     def build_context(self, formvalues=None):
         """build form context values (the .context attribute which is a
         dictionary with field instance as key associated to a dictionary
@@ -217,7 +217,7 @@
         a string).
         """
         if self.formvalues is not None:
-            return # already built
+            return  # already built
         self.formvalues = formvalues or {}
         # use a copy in case fields are modified while context is built (eg
         # __linkto handling for instance)
@@ -239,6 +239,7 @@
                             eidparam=True)
 
     _default_form_action_path = 'edit'
+
     def form_action(self):
         action = self.action
         if action is None:
@@ -256,7 +257,7 @@
                 editedfields = self._cw.form['_cw_fields']
             except KeyError:
                 raise RequestError(self._cw._('no edited fields specified'))
-        entityform = entity and len(inspect.getargspec(self.field_by_name)) == 4 # XXX
+        entityform = entity and len(inspect.getargspec(self.field_by_name)) == 4  # XXX
         for editedfield in splitstrip(editedfields):
             try:
                 name, role = editedfield.split('-')
@@ -275,7 +276,7 @@
         will return a dictionary with field names as key and typed value as
         associated value.
         """
-        with tempattr(self, 'formvalues', {}): # init fields value cache
+        with tempattr(self, 'formvalues', {}):  # init fields value cache
             errors = []
             processed = {}
             for field in self.iter_modified_fields():
@@ -441,7 +442,7 @@
     def actual_eid(self, eid):
         # should be either an int (existant entity) or a variable (to be
         # created entity)
-        assert eid or eid == 0, repr(eid) # 0 is a valid eid
+        assert eid or eid == 0, repr(eid)  # 0 is a valid eid
         try:
             return int(eid)
         except ValueError:
@@ -470,8 +471,8 @@
 
     def build_context(self, formvalues=None):
         super(CompositeFormMixIn, self).build_context(formvalues)
-        for form in self.forms:
-            form.build_context(formvalues)
+        for form_ in self.forms:
+            form_.build_context(formvalues)
 
 
 class CompositeForm(CompositeFormMixIn, FieldsForm):
@@ -479,5 +480,6 @@
     at once.
     """
 
+
 class CompositeEntityForm(CompositeFormMixIn, EntityFieldsForm):
-    pass # XXX why is this class necessary?
+    pass  # XXX why is this class necessary?
--- a/cubicweb/web/views/staticcontrollers.py	Thu Nov 24 16:58:27 2016 +0100
+++ b/cubicweb/web/views/staticcontrollers.py	Thu Nov 24 16:58:50 2016 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -39,7 +39,6 @@
 from cubicweb.web.views.urlrewrite import URLRewriter
 
 
-
 class StaticFileController(Controller):
     """an abtract class to serve static file
 
@@ -49,7 +48,7 @@
 
     def max_age(self, path):
         """max cache TTL"""
-        return 60*60*24*7
+        return 60 * 60 * 24 * 7
 
     def static_file(self, path):
         """Return full content of a static file.
@@ -248,9 +247,11 @@
         relpath = self.relpath[len(self.__regid__) + 1:]
         return self.static_file(osp.join(staticdir, relpath))
 
+
 STATIC_CONTROLLERS = [DataController, FCKEditorController,
                       StaticDirectoryController]
 
+
 class StaticControlerRewriter(URLRewriter):
     """a quick and dirty rewritter in charge of server static file.
 
@@ -267,6 +268,5 @@
         else:
             self.debug("not a static file uri: %s", uri)
             raise KeyError(uri)
-        relpath = self._cw.relative_path(includeparams=False)
         self._cw.form['static_relative_path'] = self._cw.relative_path(includeparams=True)
         return ctrl.__regid__, None
--- a/flake8-ok-files.txt	Thu Nov 24 16:58:27 2016 +0100
+++ b/flake8-ok-files.txt	Thu Nov 24 16:58:50 2016 +0100
@@ -1,3 +1,5 @@
+cubicweb/__init__.py
+cubicweb/__main__.py
 cubicweb/dataimport/csv.py
 cubicweb/dataimport/importer.py
 cubicweb/dataimport/massive_store.py
@@ -20,14 +22,15 @@
 cubicweb/entities/adapters.py
 cubicweb/entities/test/unittest_base.py
 cubicweb/etwist/__init__.py
+cubicweb/etwist/request.py
+cubicweb/etwist/service.py
 cubicweb/ext/__init__.py
 cubicweb/hooks/test/data/hooks.py
 cubicweb/hooks/test/unittest_notification.py
 cubicweb/hooks/test/unittest_security.py
 cubicweb/hooks/test/unittest_syncsession.py
-cubicweb/__init__.py
-cubicweb/__main__.py
 cubicweb/pylintext.py
+cubicweb/rset.py
 cubicweb/server/repository.py
 cubicweb/server/rqlannotation.py
 cubicweb/server/schema2sql.py
@@ -71,6 +74,7 @@
 cubicweb/test/unittest_binary.py
 cubicweb/test/unittest_mail.py
 cubicweb/test/unittest_repoapi.py
+cubicweb/test/unittest_req.py
 cubicweb/test/unittest_schema.py
 cubicweb/test/unittest_toolsutils.py
 cubicweb/test/unittest_utils.py
@@ -80,8 +84,10 @@
 cubicweb/web/test/unittest_views_basetemplates.py
 cubicweb/web/test/unittest_views_cwsources.py
 cubicweb/web/test/unittest_views_json.py
+cubicweb/web/views/editcontroller.py
 cubicweb/web/views/json.py
 cubicweb/web/views/searchrestriction.py
+cubicweb/web/views/staticcontrollers.py
 cubicweb/web/views/uicfg.py
 cubicweb/xy.py
 cubicweb/pyramid/auth.py