From e0d85fbc44828dab6d447285c4d914a295b58e6a Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sat, 29 Mar 2014 10:57:02 -0300 Subject: [PATCH] Make it work with two plugins. bottle>=0.10 changed behaviour to replace plugins with the same name, so I have to patch the name if a plugin with the same name already exists. --- bottle_sqlite.py | 2 ++ test.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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()