src/pyams_utils/vocabulary.py
branchdev-tf
changeset 408 cf2304af0fab
parent 367 2c95d34496f5
--- a/src/pyams_utils/vocabulary.py	Wed Nov 20 19:26:23 2019 +0100
+++ b/src/pyams_utils/vocabulary.py	Fri Nov 22 18:51:37 2019 +0100
@@ -15,8 +15,6 @@
 This module is used to handle vocabularies.
 """
 
-__docformat__ = 'restructuredtext'
-
 import logging
 
 import venusian
@@ -25,10 +23,13 @@
 from zope.schema.vocabulary import getVocabularyRegistry
 
 
-logger = logging.getLogger('PyAMS (utils)')
+__docformat__ = 'restructuredtext'
 
 
-class vocabulary_config:
+LOGGER = logging.getLogger('PyAMS (utils)')
+
+
+class vocabulary_config:  # pylint: disable=invalid-name
     """Class decorator to define a vocabulary
 
     :param str name: name of the registered vocabulary
@@ -48,7 +49,8 @@
             '''ZEO connections vocabulary'''
 
             def __init__(self, context=None):
-                terms = [SimpleTerm(name, title=util.name) for name, util in get_utilities_for(IZEOConnection)]
+                terms = [SimpleTerm(name, title=util.name)
+                         for name, util in get_utilities_for(IZEOConnection)]
                 super(ZEOConnectionVocabulary, self).__init__(terms)
 
     You can then use such a vocabulary in any schema field:
@@ -77,20 +79,21 @@
         settings = self.__dict__.copy()
         depth = settings.pop('_depth', 0)
 
-        def callback(context, name, ob):
-            logger.debug('Registering class {0} as vocabulary with name "{1}"'.format(str(ob), self.name))
-            directlyProvides(ob, IVocabularyFactory)
-            getVocabularyRegistry().register(self.name, ob)
+        def callback(context, name, obj):  # pylint: disable=unused-argument
+            LOGGER.debug('Registering class {0} as vocabulary with name "{1}"'.format(
+                str(obj), self.name))
+            directlyProvides(obj, IVocabularyFactory)
+            getVocabularyRegistry().register(self.name, obj)
 
         info = self.venusian.attach(wrapped, callback, category='pyams_vocabulary',
                                     depth=depth + 1)
 
-        if info.scope == 'class':
+        if info.scope == 'class':  # pylint: disable=no-member
             # if the decorator was attached to a method in a class, or
             # otherwise executed at class scope, we need to set an
             # 'attr' into the settings if one isn't already in there
             if settings.get('attr') is None:
                 settings['attr'] = wrapped.__name__
 
-        settings['_info'] = info.codeinfo  # fbo "action_method"
+        settings['_info'] = info.codeinfo  # pylint: disable=no-member
         return wrapped