summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLakin Wecker <devnull@localhost>2008-10-30 15:05:37 +0000
committerLakin Wecker <devnull@localhost>2008-10-30 15:05:37 +0000
commit602c4db36d1d529bec93d8e3dcbc408aaa7fe6a5 (patch)
tree4f23db04c892e9f15a64072ab43f3a419965f17a
parent31ba9cd03e025ba88ccf560802813f66c23bdb34 (diff)
downloadcherrypy-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.py4
-rw-r--r--cherrypy/test/test_objectmapping.py8
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: