Chris McDonough
2009-08-04 21a9c5046e0772f496e41a75e45e7d3825f9a294
- Fixed an issue that caused the following symptom when using the
ini configuration parser:

TypeError: _makePlugin() got multiple values for keyword argument 'name'

See http://bugs.repoze.org/issue92 for more details. Thanks to vaab
for the bug report and initial fix.


3 files modified
34 ■■■■ changed files
CHANGES.txt 9 ●●●● patch | view | raw | blame | history
repoze/who/config.py 8 ●●●●● patch | view | raw | blame | history
repoze/who/tests/test_config.py 17 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -5,7 +5,14 @@
Next release
============
- ...
- Fixed an issue that caused the following symptom when using the
  ini configuration parser:
  TypeError: _makePlugin() got multiple values for keyword argument 'name'
  See http://bugs.repoze.org/issue92 for more details.  Thanks to vaab
  for the bug report and initial fix.
1.0.15 (2009/06/25)
===================
repoze/who/config.py
@@ -31,10 +31,12 @@
        self.mdproviders = []
        self.remote_user_key = 'REMOTE_USER'
    def _makePlugin(self, name, iface, **kw):
    def _makePlugin(self, name, iface, options=None):
        if options is None:
            options = {}
        obj = _resolve(name)
        if not iface.providedBy(obj):
            obj = obj(**kw)
            obj = obj(**options)
        return obj
    def _getPlugin(self, name, iface):
@@ -75,7 +77,7 @@
            if 'use' in options:
                name = options.pop('use')
                del options['here']
                obj = self._makePlugin(name, IPlugin, **options)
                obj = self._makePlugin(name, IPlugin, options)
                self.plugins[plugin_id] = obj
        if 'general' in cp.sections():
repoze/who/tests/test_config.py
@@ -213,6 +213,16 @@
        self.assertEqual(second[0], 'bar')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
    def test_parse_make_plugin_names(self):
        # see http://bugs.repoze.org/issue92
        config = self._makeOne()
        config.parse(MAKE_PLUGIN_ARG_NAMES)
        self.assertEqual(len(config.plugins), 1)
        foo = config.plugins['foo']
        self.failUnless(isinstance(foo, DummyPlugin))
        self.assertEqual(foo.iface, 'iface')
        self.assertEqual(foo.name, 'name')
class DummyPlugin:
    def __init__(self, **kw):
        self.__dict__.update(kw)
@@ -325,6 +335,13 @@
use = repoze.who.tests.test_config:DummyPlugin
"""
MAKE_PLUGIN_ARG_NAMES = """\
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
name = name
iface = iface
"""
class TestConfigMiddleware(unittest.TestCase):
    tempdir = None