diff --git a/bottle_sqlite.py b/bottle_sqlite.py index 434801c..f9de278 100755 --- a/bottle_sqlite.py +++ b/bottle_sqlite.py @@ -67,6 +67,8 @@ class SQLitePlugin(object): if other.keyword == self.keyword: raise PluginError("Found another sqlite plugin with "\ "conflicting settings (non-unique keyword).") + elif other.name == self.name: + self.name += '_%s' % self.keyword def apply(self, callback, route): # hack to support bottle v0.9.x diff --git a/test.py b/test.py index d4024ec..fb50d9e 100644 --- a/test.py +++ b/test.py @@ -28,6 +28,18 @@ class SQLiteTest(unittest.TestCase): def test(**kw): self.assertFalse('db' in kw) self.app({'PATH_INFO':'/2', 'REQUEST_METHOD':'GET'}, lambda x, y: None) - + + def test_install_conflicts(self): + self.app.install(sqlite.Plugin()) + self.app.install(sqlite.Plugin(keyword='db2')) + + @self.app.get('/') + def test(db, db2): + pass + + # I have two plugins working with different names + self.app({'PATH_INFO': '/', 'REQUEST_METHOD': 'GET'}, lambda x, y: None) + + if __name__ == '__main__': unittest.main()