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.
This commit is contained in:
parent
b5fe085f96
commit
e0d85fbc44
|
@ -67,6 +67,8 @@ class SQLitePlugin(object):
|
||||||
if other.keyword == self.keyword:
|
if other.keyword == self.keyword:
|
||||||
raise PluginError("Found another sqlite plugin with "\
|
raise PluginError("Found another sqlite plugin with "\
|
||||||
"conflicting settings (non-unique keyword).")
|
"conflicting settings (non-unique keyword).")
|
||||||
|
elif other.name == self.name:
|
||||||
|
self.name += '_%s' % self.keyword
|
||||||
|
|
||||||
def apply(self, callback, route):
|
def apply(self, callback, route):
|
||||||
# hack to support bottle v0.9.x
|
# hack to support bottle v0.9.x
|
||||||
|
|
12
test.py
12
test.py
|
@ -29,5 +29,17 @@ class SQLiteTest(unittest.TestCase):
|
||||||
self.assertFalse('db' in kw)
|
self.assertFalse('db' in kw)
|
||||||
self.app({'PATH_INFO':'/2', 'REQUEST_METHOD':'GET'}, lambda x, y: None)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user