diff options
author | Lakin Wecker <devnull@localhost> | 2008-10-30 15:05:37 +0000 |
---|---|---|
committer | Lakin Wecker <devnull@localhost> | 2008-10-30 15:05:37 +0000 |
commit | 602c4db36d1d529bec93d8e3dcbc408aaa7fe6a5 (patch) | |
tree | 4f23db04c892e9f15a64072ab43f3a419965f17a | |
parent | 31ba9cd03e025ba88ccf560802813f66c23bdb34 (diff) | |
download | cherrypy-602c4db36d1d529bec93d8e3dcbc408aaa7fe6a5.tar.gz |
Allow apps to be mounted with the same script_name passed in as they are already instantiated with. Fumanchu asked for this earlier, or at least wondered about it. I realized it would allow apps to be compatible with both CP 3.1 and CP Trunk so I added it.
-rw-r--r-- | cherrypy/_cptree.py | 4 | ||||
-rw-r--r-- | cherrypy/test/test_objectmapping.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/cherrypy/_cptree.py b/cherrypy/_cptree.py index b5797478..36d00865 100644 --- a/cherrypy/_cptree.py +++ b/cherrypy/_cptree.py @@ -170,8 +170,8 @@ class Tree(object): if isinstance(root, Application): app = root - if script_name != "": - raise ValueError, "Cannot specify a script name and pass an Application instance to cherrypy.mount" + if script_name != "" and script_name != app.script_name: + raise ValueError, "Cannot specify a different script name and pass an Application instance to cherrypy.mount" script_name = app.script_name else: app = Application(root, script_name) diff --git a/cherrypy/test/test_objectmapping.py b/cherrypy/test/test_objectmapping.py index 23e251e0..c67fbfcf 100644 --- a/cherrypy/test/test_objectmapping.py +++ b/cherrypy/test/test_objectmapping.py @@ -331,6 +331,14 @@ class ObjectMappingTest(helper.CPWebCase): a = Application(object(), '/somewhere') self.assertRaises(ValueError, cherrypy.tree.mount, a, '/somewhereelse') + # When mounting an application instance, + # we can't specify a script name in the call to mount. + a = Application(object(), '/somewhere') + try: + cherrypy.tree.mount(a, '/somewhere') + except ValueError: + self.fail("tree.mount must allow script_names which are the same") + try: cherrypy.tree.mount(a) except ValueError: |