New submission from LAB <valentin....@securactive.net>:
Plugins with variable 'name' of 'iface' as this sample:
[plugin:foo]
name = bar
use = repoze.who.tests.test_config:DummyPlugin
... will trigger a
TypeError: _makePlugin() got multiple values for keyword argument 'name'
... at line 78 in config.py, which is:
obj = self._makePlugin(name, IPlugin, **options)
'options' contains the dict associating the variable name to it parsed value, so
when containing a 'name' or 'iface' keyword it collides with the _makePlugin
prototype which is:
def _makePlugin(self, name, iface, **kw):
This is a nasty bug since sql authenticator needs a 'name' option !
So I provided a simple fixe along with it's test. I hope I missed nothing.
----------
files: argument-collision.patch
messages: 246
nosy: vaab
priority: bug
status: unread
title: plugin vars collide with 'name' or 'iface' from WhoConfig._makePlugin
prototype
__________________________________
Repoze Bugs <b...@bugs.repoze.org>
<http://bugs.repoze.org/issue92>
__________________________________
diff --git a/trunk/repoze/who/config.py b/trunk/repoze/who/config.py
index c376616..2842dc5 100644
--- a/trunk/repoze/who/config.py
+++ b/trunk/repoze/who/config.py
@@ -31,7 +31,9 @@ class WhoConfig:
self.mdproviders = []
self.remote_user_key = 'REMOTE_USER'
- def _makePlugin(self, name, iface, **kw):
+ def _makePlugin(self, name, iface, kw = None):
+ if kw is None:
+ kw = {}
obj = _resolve(name)
if not iface.providedBy(obj):
obj = obj(**kw)
@@ -75,7 +77,7 @@ class WhoConfig:
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():
diff --git a/trunk/repoze/who/tests/test_config.py b/trunk/repoze/who/tests/test_config.py
index 243e3d4..840c323 100644
--- a/trunk/repoze/who/tests/test_config.py
+++ b/trunk/repoze/who/tests/test_config.py
@@ -61,6 +61,13 @@ class TestWhoConfig(unittest.TestCase):
self.failUnless(isinstance(bar, DummyPlugin))
self.assertEqual(bar.credentials, 'qux')
+ def test_parse_plugins_var_collision_check(self):
+ config = self._makeOne()
+ config.parse(PLUGIN_WITH_NAME_VAR)
+ foo = config.plugins['foo']
+ self.failUnless(isinstance(foo, DummyPlugin))
+ self.assertEqual(foo.name, 'bar')
+
def test_parse_general_empty(self):
config = self._makeOne()
config.parse('[general]')
@@ -325,6 +332,12 @@ use = repoze.who.tests.test_config:DummyPlugin
use = repoze.who.tests.test_config:DummyPlugin
"""
+PLUGIN_WITH_NAME_VAR = """\
+[plugin:foo]
+name = bar
+use = repoze.who.tests.test_config:DummyPlugin
+"""
+
class TestConfigMiddleware(unittest.TestCase):
tempdir = None
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev