[FIX] Extension of controller in-place with explicit spec of same _cp_path

When extending a controller in-place (e.g. A(Controller), B(A)) and
providing the exact same _cp_path as parent (no-op) execution path
would go into handler for _cp_path overwriting and raise an assertion
error for overwriting of existing controller.

Except this is allowed (if ugly) pattern, so warn & ignore behavior
(it is harmless).

bzr revid: xmo@openerp.com-20130418092405-wrmmrd648b9koefu
This commit is contained in:
Xavier Morel
2013-04-18 11:24:05 +02:00
parent 3df2a146cd
commit db4d08e3a9
2 changed files with 30 additions and 1 deletions
+23
View File
@@ -242,6 +242,29 @@ class TestSubclassing(DispatchCleanup):
self.assertEqual('200 OK', status)
self.assertEqual('1 2 3', ''.join(body))
def test_extends_same_path(self):
"""
When subclassing an existing Controller and specifying the same
_cp_path as the parent, ???
"""
class A(http.Controller):
_cp_path = '/foo'
@http.httprequest
def index(self, req):
return '1'
class B(A):
_cp_path = '/foo'
@http.httprequest
def index(self, req):
return '2'
self.app.load_addons()
body, status, headers = self.client.get('/foo')
self.assertEqual('200 OK', status)
self.assertEqual('2', ''.join(body))
def test_re_expose(self):
"""
An existing Controller should not be extended with a new cp_path